From 8a41d369f2e44c87a2ee25679f6c44b197cf5742 Mon Sep 17 00:00:00 2001 From: ben-toogood Date: Tue, 17 Mar 2020 16:59:57 +0000 Subject: [PATCH] Auth JWT ID Fix (#1359) * Auth JWT ID Fix * Remove unused ID in jwt claims Co-authored-by: Ben Toogood --- auth/jwt/jwt.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/auth/jwt/jwt.go b/auth/jwt/jwt.go index 49e1ff19..4db68d61 100644 --- a/auth/jwt/jwt.go +++ b/auth/jwt/jwt.go @@ -52,7 +52,6 @@ func (s *svc) Init(opts ...auth.Option) error { // AuthClaims to be encoded in the JWT type AuthClaims struct { - Id string `json:"id"` Roles []*auth.Role `json:"roles"` Metadata map[string]string `json:"metadata"` @@ -74,7 +73,7 @@ func (s *svc) Generate(id string, ops ...auth.GenerateOption) (*auth.Account, er options := auth.NewGenerateOptions(ops...) account := jwt.NewWithClaims(jwt.SigningMethodRS256, AuthClaims{ - id, options.Roles, options.Metadata, jwt.StandardClaims{ + options.Roles, options.Metadata, jwt.StandardClaims{ Subject: id, ExpiresAt: options.Expiry.Unix(), }, @@ -127,7 +126,7 @@ func (s *svc) Verify(token string) (*auth.Account, error) { } return &auth.Account{ - Id: claims.Id, + Id: claims.Subject, Metadata: claims.Metadata, Roles: claims.Roles, }, nil