From 9f9c748f9bb9a0ade744e36100c903fb0087ef12 Mon Sep 17 00:00:00 2001 From: ben-toogood Date: Tue, 14 Jul 2020 12:16:52 +0100 Subject: [PATCH] auth/service: fix account issuer bug (#1834) --- auth/service/service.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/auth/service/service.go b/auth/service/service.go index f62b5c6d..2c07016c 100644 --- a/auth/service/service.go +++ b/auth/service/service.go @@ -43,6 +43,9 @@ func (s *svc) Options() auth.Options { // Generate a new account func (s *svc) Generate(id string, opts ...auth.GenerateOption) (*auth.Account, error) { 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 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, Scopes: options.Scopes, Metadata: options.Metadata, - Issuer: s.Options().Issuer, + Issuer: options.Issuer, } 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, Provider: options.Provider, Options: &pb.Options{ - Namespace: s.Options().Issuer, + Namespace: options.Issuer, }, }, s.callOpts()...) if err != nil {