| 123456789101112131415161718192021222324252627 |
- package middleware
- import (
- "time"
- "device-manage/app/admin/middleware/handler"
- jwt "device-manage/pkg/jwtauth"
- "device-manage/tools/config"
- )
- func AuthInit() (*jwt.GinJWTMiddleware, error) {
- return jwt.New(&jwt.GinJWTMiddleware{
- Realm: "test zone",
- Key: []byte(config.ApplicationConfig.JwtSecret),
- Timeout: time.Hour,
- MaxRefresh: time.Hour,
- PayloadFunc: handler.PayloadFunc,
- IdentityHandler: handler.IdentityHandler,
- Authenticator: handler.Authenticator,
- Authorizator: handler.Authorizator,
- Unauthorized: handler.Unauthorized,
- TokenLookup: "header: Authorization, query: token, cookie: jwt",
- TokenHeadName: "Bearer",
- TimeFunc: time.Now,
- })
- }
|