Changeset 0.24.0 (#156)
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"git.gobha.me/xcaliber/chat-switchboard/auth"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/compaction"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/config"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/crypto"
|
||||
@@ -329,7 +330,22 @@ func main() {
|
||||
base.GET("/ws", middleware.Auth(cfg), hub.HandleWebSocket)
|
||||
|
||||
// ── Auth routes (rate limited) ──────────────
|
||||
auth := handlers.NewAuthHandler(cfg, stores, uekCache)
|
||||
authMode, err := auth.ParseMode(cfg.AuthMode)
|
||||
if err != nil {
|
||||
log.Fatalf("❌ Invalid AUTH_MODE=%q: %v", cfg.AuthMode, err)
|
||||
}
|
||||
var authProvider auth.Provider
|
||||
switch authMode {
|
||||
case auth.ModeBuiltin:
|
||||
authProvider = auth.NewBuiltinProvider()
|
||||
case auth.ModeMTLS:
|
||||
log.Fatal("❌ AUTH_MODE=mtls is not yet implemented (planned for v0.24.1)")
|
||||
case auth.ModeOIDC:
|
||||
log.Fatal("❌ AUTH_MODE=oidc is not yet implemented (planned for v0.24.1)")
|
||||
}
|
||||
log.Printf(" 🔑 Auth mode: %s", authMode)
|
||||
|
||||
authH := handlers.NewAuthHandler(cfg, stores, uekCache, authProvider)
|
||||
authLimiter := middleware.NewRateLimiter(1, 5)
|
||||
|
||||
api := base.Group("/api/v1")
|
||||
@@ -353,10 +369,10 @@ func main() {
|
||||
authGroup := api.Group("/auth")
|
||||
authGroup.Use(authLimiter.Limit())
|
||||
{
|
||||
authGroup.POST("/register", auth.Register)
|
||||
authGroup.POST("/login", auth.Login)
|
||||
authGroup.POST("/refresh", auth.Refresh)
|
||||
authGroup.POST("/logout", auth.Logout)
|
||||
authGroup.POST("/register", authH.Register)
|
||||
authGroup.POST("/login", authH.Login)
|
||||
authGroup.POST("/refresh", authH.Refresh)
|
||||
authGroup.POST("/logout", authH.Logout)
|
||||
}
|
||||
|
||||
// ── Public extension assets ────────────────
|
||||
|
||||
Reference in New Issue
Block a user