From 7ee07a12481fa47a20fac60ab1a37c52f915ef90 Mon Sep 17 00:00:00 2001 From: Ruslan Nasyrov Date: Thu, 17 Oct 2024 12:16:29 +0500 Subject: [PATCH] changed timeout type Signed-off-by: Ruslan Nasyrov --- plugins/auth-backend-module-oidc-provider/config.d.ts | 2 ++ plugins/auth-backend-module-oidc-provider/package.json | 1 + .../src/authenticator.ts | 10 +++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/auth-backend-module-oidc-provider/config.d.ts b/plugins/auth-backend-module-oidc-provider/config.d.ts index 409c658c23..4c7c435e54 100644 --- a/plugins/auth-backend-module-oidc-provider/config.d.ts +++ b/plugins/auth-backend-module-oidc-provider/config.d.ts @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { HumanDuration } from '@backstage/types'; import { HumanDuration } from '@backstage/types'; @@ -33,6 +34,7 @@ export interface Config { tokenSignedResponseAlg?: string; additionalScopes?: string | string[]; prompt?: string; + timeout?: HumanDuration; signIn?: { resolvers: Array< | { diff --git a/plugins/auth-backend-module-oidc-provider/package.json b/plugins/auth-backend-module-oidc-provider/package.json index 3de2277163..3e82e6183e 100644 --- a/plugins/auth-backend-module-oidc-provider/package.json +++ b/plugins/auth-backend-module-oidc-provider/package.json @@ -37,6 +37,7 @@ "@backstage/backend-plugin-api": "workspace:^", "@backstage/plugin-auth-backend": "workspace:^", "@backstage/plugin-auth-node": "workspace:^", + "@backstage/types": "workspace:^", "express": "^4.18.2", "openid-client": "^5.5.0", "passport": "^0.7.0" diff --git a/plugins/auth-backend-module-oidc-provider/src/authenticator.ts b/plugins/auth-backend-module-oidc-provider/src/authenticator.ts index ece4776bf8..9c4589a73e 100644 --- a/plugins/auth-backend-module-oidc-provider/src/authenticator.ts +++ b/plugins/auth-backend-module-oidc-provider/src/authenticator.ts @@ -32,6 +32,7 @@ import { PassportOAuthAuthenticatorHelper, PassportOAuthPrivateInfo, } from '@backstage/plugin-auth-node'; +import { durationToMilliseconds, HumanDuration } from '@backstage/types'; const HTTP_OPTION_TIMEOUT = 10000; const createHttpOptionsProvider = @@ -86,8 +87,15 @@ export const oidcAuthenticator = createOAuthAuthenticator({ 'The oidc provider no longer supports the "scope" configuration option. Please use the "additionalScopes" option instead.', ); } + + const timeoutHumanDuration = config.getOptional('timeout'); + const timeoutMilliseconds = + typeof timeoutHumanDuration === 'object' + ? durationToMilliseconds(timeoutHumanDuration) + : undefined; + const httpOptionsProvider = createHttpOptionsProvider({ - timeout: config.getOptionalNumber('timeout'), + timeout: timeoutMilliseconds, }); Issuer[custom.http_options] = httpOptionsProvider;