Files
ai-agent/internal/middleware/auth_middleware.go
T
t 2bbf42b741 refactor(auth): delegate access control to be-system
Remove Agent Desk users, roles, login sessions, tokens, and local permission persistence. Expose the backend as an embeddable ai-agent module with host-provided subject lookup and operation authorization callbacks, and complete the frontend/backend repository split.
2026-08-21 00:41:07 +08:00

28 lines
570 B
Go

package middleware
import (
"code.tczkiot.com/wlw/ai-agent/internal/pkg/i18nx"
"code.tczkiot.com/wlw/ai-agent/internal/services"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
)
func AuthMiddleware(ctx *gin.Context) {
if !authenticateRequest(ctx) {
return
}
ctx.Next()
}
func authenticateRequest(ctx *gin.Context) bool {
if _, err := services.AuthService.Authenticate(ctx); err != nil {
result := web.JsonError(err)
result.Message = i18nx.T(ctx, "error.auth.expired")
ctx.JSON(200, result)
ctx.Abort()
return false
}
return true
}