Auth JWT ID Fix (#1359)

* Auth JWT ID Fix

* Remove unused ID in jwt claims

Co-authored-by: Ben Toogood <ben@micro.mu>
This commit is contained in:
ben-toogood 2020-03-17 16:59:57 +00:00 committed by GitHub
parent 638c219736
commit 8a41d369f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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