auth-backend-module-oidc-provider: set http request timeout on a per-request basis
Signed-off-by: Dmitry Gusev <gusevda90@gmail.com>
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
import {
|
||||
custom,
|
||||
CustomHttpOptionsProvider,
|
||||
Issuer,
|
||||
ClientAuthMethod,
|
||||
TokenSet,
|
||||
@@ -31,9 +32,13 @@ import {
|
||||
PassportOAuthPrivateInfo,
|
||||
} from '@backstage/plugin-auth-node';
|
||||
|
||||
custom.setHttpOptionsDefaults({
|
||||
timeout: 10000,
|
||||
});
|
||||
const HTTP_OPTION_TIMEOUT = 10000;
|
||||
const httpOptionsProvider: CustomHttpOptionsProvider = (_url, options) => {
|
||||
return {
|
||||
...options,
|
||||
timeout: HTTP_OPTION_TIMEOUT,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* authentication result for the OIDC which includes the token set and user
|
||||
@@ -71,7 +76,11 @@ export const oidcAuthenticator = createOAuthAuthenticator({
|
||||
const initializedScope = config.getOptionalString('scope');
|
||||
const initializedPrompt = config.getOptionalString('prompt');
|
||||
|
||||
Issuer[custom.http_options] = httpOptionsProvider;
|
||||
const promise = Issuer.discover(metadataUrl).then(issuer => {
|
||||
issuer[custom.http_options] = httpOptionsProvider;
|
||||
issuer.Client[custom.http_options] = httpOptionsProvider;
|
||||
|
||||
const client = new issuer.Client({
|
||||
access_type: 'offline', // this option must be passed to provider to receive a refresh token
|
||||
client_id: clientId,
|
||||
@@ -83,6 +92,7 @@ export const oidcAuthenticator = createOAuthAuthenticator({
|
||||
id_token_signed_response_alg: tokenSignedResponseAlg || 'RS256',
|
||||
scope: initializedScope || '',
|
||||
});
|
||||
client[custom.http_options] = httpOptionsProvider;
|
||||
|
||||
const strategy = new OidcStrategy(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user