forked from baron/baron-sso
golangci-lint gofmt/gofumpt 적용
This commit is contained in:
@@ -3,9 +3,9 @@ package handler
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/descope/go-sdk/descope"
|
"github.com/descope/go-sdk/descope"
|
||||||
"github.com/descope/go-sdk/descope/client"
|
"github.com/descope/go-sdk/descope/client"
|
||||||
@@ -76,7 +76,9 @@ func (h *AdminHandler) CheckAuth(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
// ListUsers - GET /api/v1/admin/users
|
// ListUsers - GET /api/v1/admin/users
|
||||||
func (h *AdminHandler) ListUsers(c *fiber.Ctx) error {
|
func (h *AdminHandler) ListUsers(c *fiber.Ctx) error {
|
||||||
if err := h.checkAuth(c); err != nil { return err }
|
if err := h.checkAuth(c); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
text := c.Query("text")
|
text := c.Query("text")
|
||||||
// Limit is not directly supported in SearchAll options as a simple int in all SDK versions,
|
// Limit is not directly supported in SearchAll options as a simple int in all SDK versions,
|
||||||
@@ -87,7 +89,7 @@ func (h *AdminHandler) ListUsers(c *fiber.Ctx) error {
|
|||||||
var err error
|
var err error
|
||||||
|
|
||||||
if text != "" {
|
if text != "" {
|
||||||
options := &descope.UserSearchOptions{ Text: text, Limit: 50 }
|
options := &descope.UserSearchOptions{Text: text, Limit: 50}
|
||||||
users, _, err = h.DescopeClient.Management.User().SearchAll(context.Background(), options)
|
users, _, err = h.DescopeClient.Management.User().SearchAll(context.Background(), options)
|
||||||
} else {
|
} else {
|
||||||
// Nil options means default search (usually returns all or default page)
|
// Nil options means default search (usually returns all or default page)
|
||||||
@@ -104,7 +106,9 @@ func (h *AdminHandler) ListUsers(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
// DeleteUser - DELETE /api/v1/admin/users/:loginId
|
// DeleteUser - DELETE /api/v1/admin/users/:loginId
|
||||||
func (h *AdminHandler) DeleteUser(c *fiber.Ctx) error {
|
func (h *AdminHandler) DeleteUser(c *fiber.Ctx) error {
|
||||||
if err := h.checkAuth(c); err != nil { return err }
|
if err := h.checkAuth(c); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
loginID := c.Params("loginId")
|
loginID := c.Params("loginId")
|
||||||
// Decode if necessary (Fiber usually decodes params, but let's be safe if it's double encoded)
|
// Decode if necessary (Fiber usually decodes params, but let's be safe if it's double encoded)
|
||||||
@@ -123,7 +127,9 @@ func (h *AdminHandler) DeleteUser(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
// UpdateUserStatus - PATCH /api/v1/admin/users/:loginId/status
|
// UpdateUserStatus - PATCH /api/v1/admin/users/:loginId/status
|
||||||
func (h *AdminHandler) UpdateUserStatus(c *fiber.Ctx) error {
|
func (h *AdminHandler) UpdateUserStatus(c *fiber.Ctx) error {
|
||||||
if err := h.checkAuth(c); err != nil { return err }
|
if err := h.checkAuth(c); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
loginID := c.Params("loginId")
|
loginID := c.Params("loginId")
|
||||||
if decoded, err := url.QueryUnescape(loginID); err == nil {
|
if decoded, err := url.QueryUnescape(loginID); err == nil {
|
||||||
@@ -161,7 +167,9 @@ func (h *AdminHandler) UpdateUserStatus(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
// UpdateUser - PATCH /api/v1/admin/users/:loginId
|
// UpdateUser - PATCH /api/v1/admin/users/:loginId
|
||||||
func (h *AdminHandler) UpdateUser(c *fiber.Ctx) error {
|
func (h *AdminHandler) UpdateUser(c *fiber.Ctx) error {
|
||||||
if err := h.checkAuth(c); err != nil { return err }
|
if err := h.checkAuth(c); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
loginID := c.Params("loginId")
|
loginID := c.Params("loginId")
|
||||||
if decoded, err := url.QueryUnescape(loginID); err == nil {
|
if decoded, err := url.QueryUnescape(loginID); err == nil {
|
||||||
@@ -213,7 +221,9 @@ func (h *AdminHandler) UpdateUser(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *AdminHandler) CreateUser(c *fiber.Ctx) error {
|
func (h *AdminHandler) CreateUser(c *fiber.Ctx) error {
|
||||||
if err := h.checkAuth(c); err != nil { return err }
|
if err := h.checkAuth(c); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if h.DescopeClient == nil {
|
if h.DescopeClient == nil {
|
||||||
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Descope Client not configured"})
|
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Descope Client not configured"})
|
||||||
|
|||||||
@@ -72,10 +72,10 @@ func NewAuthHandler(redisService *service.RedisService) *AuthHandler {
|
|||||||
RedisService: redisService,
|
RedisService: redisService,
|
||||||
DescopeClient: descopeClient,
|
DescopeClient: descopeClient,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendSms sends a verification code via SMS. (Restored for completeness)
|
// SendSms sends a verification code via SMS. (Restored for completeness)
|
||||||
func (h *AuthHandler) SendSms(c *fiber.Ctx) error {
|
func (h *AuthHandler) SendSms(c *fiber.Ctx) error {
|
||||||
var req domain.SmsRequest
|
var req domain.SmsRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "Invalid request body"})
|
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "Invalid request body"})
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
package repository
|
package repository
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"baron-sso-backend/internal/domain"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"baron-sso-backend/internal/domain"
|
|
||||||
|
|
||||||
"github.com/ClickHouse/clickhouse-go/v2"
|
"github.com/ClickHouse/clickhouse-go/v2"
|
||||||
"github.com/ClickHouse/clickhouse-go/v2/lib/driver"
|
"github.com/ClickHouse/clickhouse-go/v2/lib/driver"
|
||||||
)
|
)
|
||||||
@@ -25,7 +24,6 @@ func NewClickHouseRepository(host string, port int, user, password, db string) (
|
|||||||
},
|
},
|
||||||
Debug: false,
|
Debug: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to open clickhouse connection: %w", err)
|
return nil, fmt.Errorf("failed to open clickhouse connection: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"baron-sso-backend/internal/domain"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"baron-sso-backend/internal/domain"
|
|
||||||
"github.com/aws/aws-sdk-go-v2/aws"
|
"github.com/aws/aws-sdk-go-v2/aws"
|
||||||
"github.com/aws/aws-sdk-go-v2/config"
|
"github.com/aws/aws-sdk-go-v2/config"
|
||||||
"github.com/aws/aws-sdk-go-v2/credentials"
|
"github.com/aws/aws-sdk-go-v2/credentials"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"baron-sso-backend/internal/domain"
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/hmac"
|
"crypto/hmac"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
@@ -14,8 +15,6 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"baron-sso-backend/internal/domain"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type SmsServiceImpl struct {
|
type SmsServiceImpl struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user