Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions packages/oidc-mock-provider/bin/oidc-mock-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const { OIDCMockProvider } = require('..');

const DEFAULT_PORT = 28200;
const DEFAULT_HOST = 'localhost';
const DEFAULT_BIND_IP_ALL = false;

const argv = require('yargs')
.option('port', {
Expand All @@ -18,6 +19,10 @@ const argv = require('yargs')
type: 'string',
desc: 'Hostname for the server to listen upon. Defaults to localhost.',
})
.option('bind_ip_all', {
type: 'boolean',
desc: 'Bind to all IPv4 and IPv6 addresses',
})
.example(
'$0 -p 28200',
'Start the OIDC mock identity provider server on port 28200'
Expand All @@ -41,6 +46,7 @@ const DEFAULT_TOKEN_PAYLOAD = {
},
port: argv.port ?? DEFAULT_PORT,
hostname: argv.host ?? DEFAULT_HOST,
bindIpAll: argv.bind_ip_all ?? DEFAULT_BIND_IP_ALL,
};
const mockIdentityProvider = await OIDCMockProvider.create(
oidcMockProviderConfig
Expand Down
10 changes: 9 additions & 1 deletion packages/oidc-mock-provider/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ export interface OIDCMockProviderConfig {
*/
hostname?: string;

/**
* Optional bind to all IPv4 and IPv6 addresses.
*/
bindIpAll?: boolean;

/**
* Optional additional fields to be returned when the OIDC configuration is accessed.
*/
Expand Down Expand Up @@ -102,7 +107,10 @@ export class OIDCMockProvider {
}

private async init(): Promise<this> {
this.httpServer.listen(this.config.port ?? 0, this.config.hostname);
this.httpServer.listen(
this.config.port ?? 0,
this.config.bindIpAll ? '::,0.0.0.0' : this.config.hostname
);
await once(this.httpServer, 'listening');
const { port } = this.httpServer.address() as AddressInfo;
this.issuer = `${
Expand Down
Loading