mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-21 02:04:09 +00:00
28 lines
733 B
Go
28 lines
733 B
Go
package middleware
|
|
|
|
import (
|
|
"go-admin/handler"
|
|
jwt "go-admin/pkg/jwtauth"
|
|
"go-admin/tools/config"
|
|
"time"
|
|
)
|
|
|
|
func AuthInit() (*jwt.GinJWTMiddleware, error) {
|
|
return jwt.New(&jwt.GinJWTMiddleware{
|
|
Realm: "test zone",
|
|
Key: []byte("secret key"),
|
|
Timeout: time.Hour,
|
|
MaxRefresh: time.Hour,
|
|
IdentityKey: config.ApplicationConfig.JwtSecret,
|
|
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,
|
|
})
|
|
|
|
}
|