diff --git a/.changeset/early-feet-lay.md b/.changeset/early-feet-lay.md new file mode 100644 index 0000000000..d6f62d1129 --- /dev/null +++ b/.changeset/early-feet-lay.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-auth-backend-module-oidc-provider': minor +--- + +Added custom timeout setting for oidc provider diff --git a/plugins/auth-backend-module-oidc-provider/src/authenticator.ts b/plugins/auth-backend-module-oidc-provider/src/authenticator.ts index c396ea7034..ece4776bf8 100644 --- a/plugins/auth-backend-module-oidc-provider/src/authenticator.ts +++ b/plugins/auth-backend-module-oidc-provider/src/authenticator.ts @@ -34,12 +34,14 @@ import { } from '@backstage/plugin-auth-node'; const HTTP_OPTION_TIMEOUT = 10000; -const httpOptionsProvider: CustomHttpOptionsProvider = (_url, options) => { - return { - ...options, - timeout: HTTP_OPTION_TIMEOUT, +const createHttpOptionsProvider = + ({ timeout }: { timeout?: number }): CustomHttpOptionsProvider => + (_url, options) => { + return { + ...options, + timeout: timeout ?? HTTP_OPTION_TIMEOUT, + }; }; -}; /** * authentication result for the OIDC which includes the token set and user @@ -84,6 +86,9 @@ export const oidcAuthenticator = createOAuthAuthenticator({ 'The oidc provider no longer supports the "scope" configuration option. Please use the "additionalScopes" option instead.', ); } + const httpOptionsProvider = createHttpOptionsProvider({ + timeout: config.getOptionalNumber('timeout'), + }); Issuer[custom.http_options] = httpOptionsProvider; const promise = Issuer.discover(metadataUrl).then(issuer => {