Skip to content

Commit cd7bc1a

Browse files
committed
chore: add retries for oidc discovery
This makes it so that if other services are not immediately available when the gateway starts, the gateway will not immediately go into
1 parent 4cbec0f commit cd7bc1a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

internal/authentication/token_verifier.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"time"
77

88
"github.com/SwissDataScienceCenter/renku-gateway/internal/config"
9+
"github.com/hashicorp/go-retryablehttp"
910
"github.com/zitadel/oidc/v2/pkg/client/rp"
1011
httphelper "github.com/zitadel/oidc/v2/pkg/http"
1112
"github.com/zitadel/oidc/v2/pkg/oidc"
@@ -53,8 +54,13 @@ func (tv tokenVerifier) verifyAccessToken(ctx context.Context, accessToken strin
5354
type tokenVerifierOption func(*tokenVerifier) error
5455

5556
func withConfig(config config.AuthorizationVerifier) tokenVerifierOption {
57+
retryingClient := retryablehttp.NewClient()
58+
retryingClient.RetryMax = 10
59+
retryingClient.RetryWaitMax = time.Second * 10
60+
retryingClient.RetryWaitMin = time.Second * 2
61+
retryingClient.Backoff = retryablehttp.RateLimitLinearJitterBackoff
5662
discover := func(issuer string) (rp.Endpoints, error) {
57-
return rp.Discover(issuer, httphelper.DefaultHTTPClient)
63+
return rp.Discover(issuer, retryingClient.StandardClient())
5864
}
5965
return func(tv *tokenVerifier) error {
6066
tv.id = config.AuthorizedParty

0 commit comments

Comments
 (0)