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:
parent
638c219736
commit
8a41d369f2
@ -52,7 +52,6 @@ func (s *svc) Init(opts ...auth.Option) error {
|
|||||||
|
|
||||||
// AuthClaims to be encoded in the JWT
|
// AuthClaims to be encoded in the JWT
|
||||||
type AuthClaims struct {
|
type AuthClaims struct {
|
||||||
Id string `json:"id"`
|
|
||||||
Roles []*auth.Role `json:"roles"`
|
Roles []*auth.Role `json:"roles"`
|
||||||
Metadata map[string]string `json:"metadata"`
|
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...)
|
options := auth.NewGenerateOptions(ops...)
|
||||||
account := jwt.NewWithClaims(jwt.SigningMethodRS256, AuthClaims{
|
account := jwt.NewWithClaims(jwt.SigningMethodRS256, AuthClaims{
|
||||||
id, options.Roles, options.Metadata, jwt.StandardClaims{
|
options.Roles, options.Metadata, jwt.StandardClaims{
|
||||||
Subject: id,
|
Subject: id,
|
||||||
ExpiresAt: options.Expiry.Unix(),
|
ExpiresAt: options.Expiry.Unix(),
|
||||||
},
|
},
|
||||||
@ -127,7 +126,7 @@ func (s *svc) Verify(token string) (*auth.Account, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &auth.Account{
|
return &auth.Account{
|
||||||
Id: claims.Id,
|
Id: claims.Subject,
|
||||||
Metadata: claims.Metadata,
|
Metadata: claims.Metadata,
|
||||||
Roles: claims.Roles,
|
Roles: claims.Roles,
|
||||||
}, nil
|
}, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user