|
47 | 47 | * A JSON object with extra client metadata to pass to openid-client. Optional.
|
48 | 48 | * Be aware that setting this object may override any other values passed to the openid client.
|
49 | 49 | * More info: https://github.com/panva/node-openid-client/tree/main/docs#new-clientmetadata-jwks-options
|
50 |
| - * env GRIST_OIDC_HTTP_TIMEOUT |
51 |
| - * The timeout in milliseconds for HTTP requests to the IdP. Defaults to 3500. |
| 50 | + * env GRIST_OIDC_SP_HTTP_TIMEOUT |
| 51 | + * The timeout in milliseconds for HTTP requests to the IdP. The default value is set to 3500 by the |
| 52 | + * openid-client library. See: https://github.com/panva/node-openid-client/blob/main/docs/README.md#customizing-http-requests |
52 | 53 | *
|
53 | 54 | * This version of OIDCConfig has been tested with Keycloak OIDC IdP following the instructions
|
54 | 55 | * at:
|
@@ -139,10 +140,7 @@ export class OIDCConfig {
|
139 | 140 | censor: true,
|
140 | 141 | });
|
141 | 142 | const httpTimeout = section.flag('httpTimeout').readInt({
|
142 |
| - envVar: 'GRIST_OIDC_HTTP_TIMEOUT', |
143 |
| - // Default value matching that of node-openid-client |
144 |
| - // See https://github.com/panva/node-openid-client/blob/main/docs/README.md#customizing-http-requests for more details. |
145 |
| - defaultValue: 3500, |
| 143 | + envVar: 'GRIST_OIDC_SP_HTTP_TIMEOUT', |
146 | 144 | });
|
147 | 145 | this._namePropertyKey = section.flag('namePropertyKey').readString({
|
148 | 146 | envVar: 'GRIST_OIDC_SP_PROFILE_NAME_ATTR',
|
@@ -180,11 +178,11 @@ export class OIDCConfig {
|
180 | 178 | this._protectionManager = new ProtectionsManager(enabledProtections);
|
181 | 179 |
|
182 | 180 | this._redirectUrl = new URL(CALLBACK_URL, spHost).href;
|
183 |
| - await this._initClient({ issuerUrl, clientId, clientSecret, extraMetadata }); |
184 |
| - |
185 | 181 | custom.setHttpOptionsDefaults({
|
186 |
| - timeout: httpTimeout, |
| 182 | + ...(httpTimeout !== undefined ? {timeout: httpTimeout} : {}), |
187 | 183 | });
|
| 184 | + await this._initClient({ issuerUrl, clientId, clientSecret, extraMetadata }); |
| 185 | + |
188 | 186 | if (this._client.issuer.metadata.end_session_endpoint === undefined &&
|
189 | 187 | !this._endSessionEndpoint && !this._skipEndSessionEndpoint) {
|
190 | 188 | throw new Error('The Identity provider does not propose end_session_endpoint. ' +
|
@@ -302,6 +300,7 @@ export class OIDCConfig {
|
302 | 300 | protected async _initClient({ issuerUrl, clientId, clientSecret, extraMetadata }:
|
303 | 301 | { issuerUrl: string, clientId: string, clientSecret: string, extraMetadata: Partial<ClientMetadata> }
|
304 | 302 | ): Promise<void> {
|
| 303 | + Issuer[custom.http_options] = () => ({}); |
305 | 304 | const issuer = await Issuer.discover(issuerUrl);
|
306 | 305 | this._client = new issuer.Client({
|
307 | 306 | client_id: clientId,
|
|
0 commit comments