feat: Added custom timeout for oidc provider

Signed-off-by: Ruslan Nasyrov <ruslan.nasyrov.f@gmail.com>
This commit is contained in:
Ruslan Nasyrov
2024-10-16 15:19:45 +05:00
parent 595cdcd67d
commit 7495edfc17
2 changed files with 15 additions and 5 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-auth-backend-module-oidc-provider': minor
---
Added custom timeout setting for oidc provider
@@ -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 => {