diff --git a/account/jwt.go b/account/jwt.go index 4843baf..6d5ee1b 100644 --- a/account/jwt.go +++ b/account/jwt.go @@ -11,6 +11,8 @@ import ( "github.com/golang-jwt/jwt/v5" ) +const AUTH_COOKIE_NAME = "auth_token" + type JWTPurpose string type VerifyTokenFunc func(claim *jwt.RegisteredClaims) error diff --git a/api/middleware/middleware.go b/api/middleware/middleware.go index 139f51a..a9913fe 100644 --- a/api/middleware/middleware.go +++ b/api/middleware/middleware.go @@ -16,7 +16,6 @@ import ( ) const DEFAULT_AUTH_CONTEXT_KEY = "user_id" -const DEFAULT_AUTH_COOKIE_NAME = "auth_token" type JapeMiddlewareFunc func(jape.Handler) jape.Handler type HttpMiddlewareFunc func(http.Handler) http.Handler @@ -76,7 +75,7 @@ func FindAuthToken(r *http.Request, cookieName string, queryParam string) string return cookie.Value } - if cookie, err := r.Cookie(DEFAULT_AUTH_COOKIE_NAME); cookie != nil && err == nil { + if cookie, err := r.Cookie(account.AUTH_COOKIE_NAME); cookie != nil && err == nil { return cookie.Value }