Add account issuers

This commit is contained in:
Ben Toogood
2020-05-21 16:41:55 +01:00
parent 856c73b341
commit 12061bd006
12 changed files with 159 additions and 228 deletions

View File

@@ -13,7 +13,6 @@ import (
type authClaims struct {
Type string `json:"type"`
Scopes []string `json:"scopes"`
Provider string `json:"provider"`
Metadata map[string]string `json:"metadata"`
jwt.StandardClaims
@@ -51,8 +50,9 @@ func (j *JWT) Generate(acc *auth.Account, opts ...token.GenerateOption) (*token.
// generate the JWT
expiry := time.Now().Add(options.Expiry)
t := jwt.NewWithClaims(jwt.SigningMethodRS256, authClaims{
acc.Type, acc.Scopes, acc.Provider, acc.Metadata, jwt.StandardClaims{
acc.Type, acc.Scopes, acc.Metadata, jwt.StandardClaims{
Subject: acc.ID,
Issuer: acc.Issuer,
ExpiresAt: expiry.Unix(),
},
})
@@ -97,9 +97,9 @@ func (j *JWT) Inspect(t string) (*auth.Account, error) {
// return the token
return &auth.Account{
ID: claims.Subject,
Issuer: claims.Issuer,
Type: claims.Type,
Scopes: claims.Scopes,
Provider: claims.Provider,
Metadata: claims.Metadata,
}, nil
}