1
0
forked from baron/baron-sso

namecard 연동

This commit is contained in:
2026-01-06 09:49:11 +09:00
parent c56368d1cb
commit c512f0f4e6
13 changed files with 693 additions and 50 deletions

View File

@@ -38,6 +38,7 @@ func main() {
// 2. Initialize Handlers
auditHandler := handler.NewAuditHandler(auditRepo)
authHandler := handler.NewAuthHandler()
// 3. Initialize Fiber
app := fiber.New(fiber.Config{
@@ -47,7 +48,10 @@ func main() {
// Middleware
app.Use(logger.New())
app.Use(recover.New())
app.Use(cors.New()) // Allow Frontend Access
app.Use(cors.New(cors.Config{
AllowOrigins: "*", // Adjust in production
AllowHeaders: "Origin, Content-Type, Accept, Authorization",
}))
app.Use(encryptcookie.New(encryptcookie.Config{
Key: getEnv("COOKIE_SECRET", "secret-key-must-be-32-bytes-long!"),
}))
@@ -64,6 +68,26 @@ func main() {
// API Group
api := app.Group("/api/v1")
api.Post("/audit", auditHandler.CreateLog)
// Auth Proxy Routes
auth := api.Group("/auth")
auth.Post("/enchanted-link/init", authHandler.InitEnchantedLink)
auth.Post("/enchanted-link/poll", authHandler.PollEnchantedLink)
auth.Post("/magic-link/verify", authHandler.VerifyMagicLink)
// Client Logging Route (For Debugging)
api.Post("/client-log", func(c *fiber.Ctx) error {
type LogReq struct {
Level string `json:"level"`
Message string `json:"message"`
}
var req LogReq
if err := c.BodyParser(&req); err != nil {
return c.SendStatus(fiber.StatusBadRequest)
}
log.Printf("[CLIENT-LOG] [%s] %s", req.Level, req.Message)
return c.SendStatus(fiber.StatusOK)
})
// Start Server
port := getEnv("PORT", "3000")