Skip to content

Commit

Permalink
Add support for passing a custom http agent
Browse files Browse the repository at this point in the history
There are times that you'd need to have a custom http agent for making
the authentication requests (via openid-client). This can allow a user
to provide their own agent so that they can proxy or do other things
that they'd like to do.

Resolves #1425
  • Loading branch information
ryanolson-aumni committed Sep 27, 2023
1 parent 3557b25 commit 223af62
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
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
6 changes: 6 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,11 @@ export interface Config {
*/
httpTimeout: number;

/**
* Instance of an HTTP agent for authentication requests.
*/
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
6 changes: 6 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,11 @@ export interface BaseConfig {
*/
httpTimeout: number;

/**
* Instance of an HTTP agent for authentication requests.
*/
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

0 comments on commit 223af62

Please sign in to comment.