update
parent
1737eec0b6
commit
c1348da5bd
|
@ -78,7 +78,7 @@ func (srv Auth) SetToken(c *gin.Context, tok string) {
|
|||
c.Header("Authorization", "Bearer "+tok)
|
||||
if srv.CookieMode {
|
||||
http.SetCookie(c.Writer, &http.Cookie{
|
||||
Name: viper.GetString("name") + "_bearer",
|
||||
Name: viper.GetString("auth.name") + "_bearer",
|
||||
MaxAge: int(srv.TokenExpire),
|
||||
Value: tok,
|
||||
SameSite: srv.CookieSameSite,
|
||||
|
@ -102,7 +102,7 @@ func (srv Auth) SetClaims(c *gin.Context, claims *Claims) error {
|
|||
func (srv Auth) GetToken(c *gin.Context) (tok string, err error) {
|
||||
tok = strings.TrimPrefix(c.Request.Header.Get("Authorization"), "Bearer ")
|
||||
if tok == "" && srv.CookieMode {
|
||||
tok, err = c.Cookie(viper.GetString("name") + "_bearer")
|
||||
tok, err = c.Cookie(viper.GetString("auth.name") + "_bearer")
|
||||
}
|
||||
if err != nil {
|
||||
err = nil
|
||||
|
@ -129,7 +129,7 @@ func (srv Auth) ClearToken(c *gin.Context) {
|
|||
c.Writer.Header().Del("Authorization")
|
||||
if srv.CookieMode {
|
||||
http.SetCookie(c.Writer, &http.Cookie{
|
||||
Name: viper.GetString("name") + "_bearer",
|
||||
Name: viper.GetString("auth.name") + "_bearer",
|
||||
MaxAge: -1,
|
||||
Value: "",
|
||||
SameSite: srv.CookieSameSite,
|
||||
|
@ -146,7 +146,7 @@ func (srv Auth) NewToken(claims Claims) (tok string, err error) {
|
|||
} else if claims.ExpiresAt < 0 {
|
||||
claims.ExpiresAt = 0
|
||||
}
|
||||
claims.Issuer = viper.GetString("name")
|
||||
claims.Issuer = viper.GetString("auth.name")
|
||||
claims.Id = xid.New().String()
|
||||
claims.Endpoint = viper.GetString("domain")
|
||||
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
|
||||
|
|
Loading…
Reference in New Issue