修改中间件结构

This commit is contained in:
zhangwenjian committed 2020-04-13 00:11:47 +08:00
1 parent 531cc6926d
commit 4106f023d0
7 files changed
+341

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
package middleware
import (
config2 "go-admin/config"
"go-admin/handler"
jwt "go-admin/pkg/jwtauth"
"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: config2.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,
})
}