update
This commit is contained in:
1 parent
f25da5f1ee
commit
1df55e75e5
72 files changed
+1401
-1559
No files matched your search
@@ -5,14 +5,13 @@ import (
|
||||
"errors"
|
||||
"github.com/dgrijalva/jwt-go"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go-admin/config"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// MapClaims type that uses the map[string]interface{} for JSON decoding
|
||||
// This is the default claims type if you don't supply one
|
||||
type MapClaims map[string]interface{}
|
||||
|
||||
// GinJWTMiddleware provides a Json-Web-Token authentication implementation. On failure, a 401 HTTP response
|
||||
@@ -81,10 +80,12 @@ type GinJWTMiddleware struct {
|
||||
// rolekey
|
||||
RKey string
|
||||
|
||||
// roleId
|
||||
RoleIdKey string
|
||||
|
||||
RoleKey string
|
||||
|
||||
// roleName
|
||||
RoleNameKey string
|
||||
|
||||
// TokenLookup is a string in the form of "<source>:<name>" that is used
|
||||
@@ -281,13 +282,12 @@ func (mw *GinJWTMiddleware) MiddlewareInit() error {
|
||||
mw.SigningAlgorithm = "HS256"
|
||||
}
|
||||
|
||||
if mw.Timeout == 0 {
|
||||
mw.Timeout = time.Hour
|
||||
if config.JwtConfig.Timeout != 0 {
|
||||
// TODO: token过期时长
|
||||
mw.Timeout = time.Hour
|
||||
mw.Timeout = time.Duration(config.JwtConfig.Timeout) * time.Second
|
||||
}
|
||||
|
||||
//mw.Timeout = time.Second*5
|
||||
|
||||
if mw.TimeFunc == nil {
|
||||
mw.TimeFunc = time.Now
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user