|
@@ -2,13 +2,14 @@ package middleware
|
|
|
|
|
|
import (
|
|
|
"github.com/golang-jwt/jwt"
|
|
|
- "iot_manager_service/app/system/model"
|
|
|
"iot_manager_service/config"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
const (
|
|
|
Authorization = "Authorization"
|
|
|
+ Audience = "audience"
|
|
|
+ Issuer = "issuser"
|
|
|
)
|
|
|
|
|
|
var EmptyKeyFunc = func(t *jwt.Token) (interface{}, error) { return []byte(config.Instance().Server.TokenSign), nil }
|
|
@@ -24,8 +25,8 @@ type Claims struct {
|
|
|
|
|
|
func GetAccessToken(userId, roleId int64, tenantId int, userName string, random string) (string, error) {
|
|
|
jwtToken := Claims{StandardClaims: jwt.StandardClaims{
|
|
|
- Audience: model.Audience,
|
|
|
- Issuer: model.Issuer,
|
|
|
+ Audience: Audience,
|
|
|
+ Issuer: Issuer,
|
|
|
ExpiresAt: time.Now().Add(2 * time.Hour).Unix(),
|
|
|
NotBefore: time.Now().Unix(),
|
|
|
},
|