From c1348da5bd7e6b5a9e4698050d95b83bc6bc677f Mon Sep 17 00:00:00 2001 From: Evan Chen Date: Sun, 9 Jan 2022 05:54:07 +0800 Subject: [PATCH] update --- auth/jwt.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/auth/jwt.go b/auth/jwt.go index 4e6f79c..f21cac5 100644 --- a/auth/jwt.go +++ b/auth/jwt.go @@ -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)