diff --git a/packages/oidc-mock-provider/bin/oidc-mock-provider.js b/packages/oidc-mock-provider/bin/oidc-mock-provider.js index d61f3436..11e7715b 100755 --- a/packages/oidc-mock-provider/bin/oidc-mock-provider.js +++ b/packages/oidc-mock-provider/bin/oidc-mock-provider.js @@ -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', { @@ -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' @@ -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 diff --git a/packages/oidc-mock-provider/src/index.ts b/packages/oidc-mock-provider/src/index.ts index 77007520..accffd1a 100644 --- a/packages/oidc-mock-provider/src/index.ts +++ b/packages/oidc-mock-provider/src/index.ts @@ -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. */ @@ -102,7 +107,10 @@ export class OIDCMockProvider { } private async init(): Promise { - this.httpServer.listen(this.config.port ?? 0, this.config.hostname); + this.httpServer.listen( + this.config.port ?? 0, + this.config.bindIpAll ? '::' : this.config.hostname + ); await once(this.httpServer, 'listening'); const { port } = this.httpServer.address() as AddressInfo; this.issuer = `${