Skip to content

Commit

Permalink
chore: refactor to pass down client instead of context
Browse files Browse the repository at this point in the history
  • Loading branch information
zepatrik committed Nov 26, 2024
1 parent e03c87b commit 6fc1c39
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions oidc/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ type Provider struct {
commonRemoteKeySet KeySet
}

func (p *Provider) remoteKeySet(ctx context.Context) KeySet {
func (p *Provider) remoteKeySet(c *http.Client) KeySet {
p.mu.RLock()
if p.commonRemoteKeySet != nil {
defer p.mu.RUnlock()
Expand All @@ -127,7 +127,7 @@ func (p *Provider) remoteKeySet(ctx context.Context) KeySet {
p.mu.Lock()
defer p.mu.Unlock()

p.commonRemoteKeySet = NewRemoteKeySet(ctx, p.jwksURL)
p.commonRemoteKeySet = NewRemoteKeySet(ClientContext(context.Background(), c), p.jwksURL)
return p.commonRemoteKeySet
}

Expand Down Expand Up @@ -353,7 +353,7 @@ func (p *Provider) UserInfo(ctx context.Context, tokenSource oauth2.TokenSource)
ct := resp.Header.Get("Content-Type")
mediaType, _, parseErr := mime.ParseMediaType(ct)
if parseErr == nil && mediaType == "application/jwt" {
payload, err := p.remoteKeySet(ctx).VerifySignature(ctx, string(body))
payload, err := p.remoteKeySet(getClient(ctx)).VerifySignature(ctx, string(body))
if err != nil {
return nil, fmt.Errorf("oidc: invalid userinfo jwt signature %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion oidc/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (p *Provider) VerifierContext(ctx context.Context, config *Config) *IDToken
// The returned verifier uses a background context for all requests to the upstream
// JWKs endpoint. To control that context, use VerifierContext instead.
func (p *Provider) Verifier(config *Config) *IDTokenVerifier {
return p.newVerifier(p.remoteKeySet(ClientContext(context.Background(), p.client)), config)
return p.newVerifier(p.remoteKeySet(p.client), config)
}

func (p *Provider) newVerifier(keySet KeySet, config *Config) *IDTokenVerifier {
Expand Down

0 comments on commit 6fc1c39

Please sign in to comment.