去除pkg/auth对tools依赖,减少循环引用可能性

This commit is contained in:
linwenxiang
2020-10-30 15:40:51 +08:00
parent 4b5b0507e9
commit 5e3e16025c
2 changed files with 13 additions and 15 deletions
+10 -1
View File
@@ -8,11 +8,20 @@ import (
"go-admin/tools/config"
)
// AuthInit jwt验证new
func AuthInit() (*jwt.GinJWTMiddleware, error) {
timeout := time.Hour
if config.ApplicationConfig.Mode == "dev" {
timeout = time.Duration(876010) * time.Hour
} else {
if config.JwtConfig.Timeout != 0 {
timeout = time.Duration(config.JwtConfig.Timeout) * time.Second
}
}
return jwt.New(&jwt.GinJWTMiddleware{
Realm: "test zone",
Key: []byte(config.ApplicationConfig.JwtSecret),
Timeout: time.Hour,
Timeout: timeout,
MaxRefresh: time.Hour,
PayloadFunc: handler.PayloadFunc,
IdentityHandler: handler.IdentityHandler,