Skip to content

Commit

Permalink
jwks lazy init (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
corbadovych authored Nov 23, 2023
1 parent ee8d47d commit 7c63be6
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pkg/sdk/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,9 @@ func New(client *api.ClientWithResponses, config *config.Config) (*Impl, error)
return nil, err
}

jwks, err := newJWKS(config)
if err != nil {
return nil, err
}

return &Impl{
client: client,
config: config,
jwks: jwks,
}, nil
}

Expand Down Expand Up @@ -92,6 +86,15 @@ func (i *Impl) ValidateShortSessionValue(shortSession string) (*entity.User, err
return nil, nil
}

if i.jwks == nil {
jwks, err := newJWKS(i.config)
if err != nil {
return nil, err
}

i.jwks = jwks
}

token, err := jwt.ParseWithClaims(shortSession, &entity.Claims{}, i.jwks.Keyfunc)
if err != nil {
return nil, errors.WithStack(err)
Expand Down

0 comments on commit 7c63be6

Please sign in to comment.