-
Notifications
You must be signed in to change notification settings - Fork 427
Description
Im trying to verify token with Verifier created by provider.
verifier := provider.Verifier(&oidc.Config{ClientID: myClientID})
rawIDToken, ok := oauth2Token.Extra("id_token").(string)
ctx,_ = context.WithTimeout(context.Background(), time.Second*10)
idToken, err:= verifier.Verify(ctx, rawIDToken)
less than in a second i got the error saying context deadline exceeded
Trying to figure out what happened I changed ctx to context.Background()
but issue still persisted.
Digging into Verify code i find out that keys are actually fetched by function
func (r *remoteKeySet)keysFromRemote(ctx context.Context)([]jose.JSONWebKey, error)
and inside goroutine there is call r.updateKeys() which does not receive a context and inside the updateKeys actually is used another context r.ctx which one assigned by Provider.
Provided is created at start of the application, and due http request for openid-configuration Im not updating it often. and due same http request I set a context for provider with a deadline for 10 seconds, just in case if there is no connection to provider.
And what happens is Verify is actually would work during first 10 seconds after provider has been created, but not considering context passed to Verify