package service import ( "git.sxidc.com/go-framework/baize/convenient/domain/auth" "git.sxidc.com/go-framework/baize/convenient/domain/auth/middlewares" "git.sxidc.com/go-framework/baize/framework/core/api" "git.sxidc.com/go-framework/baize/framework/core/application" "git.sxidc.com/go-framework/baize/framework/core/infrastructure" ) func AuthMiddleware(i *infrastructure.Infrastructure) api.Handler { return func(c *api.Context) { middlewares.Authentication(dbSchema, jwtSecretKey)(c, i) } } var authService = &AuthService{} type AuthService struct{} func (svc *AuthService) Init(appInstance *application.App) error { svc.prefixRoot(appInstance) return nil } func (svc *AuthService) Destroy() error { return nil } func (svc *AuthService) prefixRoot(appInstance *application.App) { auth.BindAuth(appInstance, &auth.Simple{ Schema: dbSchema, AESKey: aesKey, JWTSecretKey: jwtSecretKey, JWTExpiredSec: 24 * 3600, AuthMiddleware: middlewares.Authentication(dbSchema, jwtSecretKey), AdminUserPassword: "123456", }) }