auth/service: fix account issuer bug (#1834)

This commit is contained in:
ben-toogood 2020-07-14 12:16:52 +01:00 committed by GitHub
parent a5e9dc21ca
commit 9f9c748f9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,6 +43,9 @@ func (s *svc) Options() auth.Options {
// Generate a new account // Generate a new account
func (s *svc) Generate(id string, opts ...auth.GenerateOption) (*auth.Account, error) { func (s *svc) Generate(id string, opts ...auth.GenerateOption) (*auth.Account, error) {
options := auth.NewGenerateOptions(opts...) options := auth.NewGenerateOptions(opts...)
if len(options.Issuer) == 0 {
options.Issuer = s.options.Issuer
}
// we have the JWT private key and generate ourselves an account // we have the JWT private key and generate ourselves an account
if len(s.options.PrivateKey) > 0 { if len(s.options.PrivateKey) > 0 {
@ -51,7 +54,7 @@ func (s *svc) Generate(id string, opts ...auth.GenerateOption) (*auth.Account, e
Type: options.Type, Type: options.Type,
Scopes: options.Scopes, Scopes: options.Scopes,
Metadata: options.Metadata, Metadata: options.Metadata,
Issuer: s.Options().Issuer, Issuer: options.Issuer,
} }
tok, err := s.jwt.Generate(acc, token.WithExpiry(time.Hour*24*365)) tok, err := s.jwt.Generate(acc, token.WithExpiry(time.Hour*24*365))
@ -73,7 +76,7 @@ func (s *svc) Generate(id string, opts ...auth.GenerateOption) (*auth.Account, e
Metadata: options.Metadata, Metadata: options.Metadata,
Provider: options.Provider, Provider: options.Provider,
Options: &pb.Options{ Options: &pb.Options{
Namespace: s.Options().Issuer, Namespace: options.Issuer,
}, },
}, s.callOpts()...) }, s.callOpts()...)
if err != nil { if err != nil {