Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for passing a custom http agent #1447

Merged
merged 6 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/auth0-session/client/node-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export class NodeClient extends AbstractClient {
}
: undefined)
},
timeout: config.httpTimeout
timeout: config.httpTimeout,
agent: config.httpAgent
});
const applyHttpOptionsCustom = (entity: Issuer<Client> | typeof Issuer | Client) => {
entity[custom.http_options] = defaultHttpOptions;
Expand Down
7 changes: 7 additions & 0 deletions src/auth0-session/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {
AuthorizationParameters as OidcAuthorizationParameters,
ClientAuthMethod
} from './client/abstract-client';
import type { Agent } from 'https';
import { SessionStore } from './session/stateful-session';

/**
Expand Down Expand Up @@ -100,6 +101,12 @@ export interface Config {
*/
httpTimeout: number;

/**
* Instance of an HTTP agent for authentication requests.
* (This is for the Node.js runtime only)
*/
httpAgent?: Agent;

/**
* Boolean value to opt-out of sending the library and Node.js version to your authorization server
* via the `Auth0-Client` header. Defaults to `true`.
Expand Down
1 change: 1 addition & 0 deletions src/auth0-session/get-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const paramsSchema = Joi.object({
),
clockTolerance: Joi.number().optional().default(60),
httpTimeout: Joi.number().optional().default(5000),
httpAgent: Joi.object().optional(),
enableTelemetry: Joi.boolean().optional().default(true),
getLoginState: Joi.function()
.optional()
Expand Down
7 changes: 7 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Agent } from 'https';
import type { LoginOptions, AuthorizationParameters as OidcAuthorizationParameters } from './auth0-session/config';
import { SessionStore } from './auth0-session/session/stateful-session';
import Session from './session/session';
Expand Down Expand Up @@ -96,6 +97,12 @@ export interface BaseConfig {
*/
httpTimeout: number;

/**
* Instance of an HTTP agent for authentication requests.
* (This is for the Node.js runtime only)
*/
httpAgent?: Agent;

/**
* Boolean value to opt-out of sending the library and node version to your authorization server
* via the `Auth0-Client` header. Defaults to `true`.
Expand Down