Skip to content

Commit a7aa434

Browse files
lerouxbaddaleax
andauthored
chore(oidc-mock-provider): allow binding to all ips while keeping a specific hostname for the issuer (#427)
* allow binding to all ips while keeping a specific hostname for the issuer * Update packages/oidc-mock-provider/src/index.ts Co-authored-by: Anna Henningsen <[email protected]> --------- Co-authored-by: Anna Henningsen <[email protected]>
1 parent 5101df2 commit a7aa434

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/oidc-mock-provider/bin/oidc-mock-provider.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const { OIDCMockProvider } = require('..');
66

77
const DEFAULT_PORT = 28200;
88
const DEFAULT_HOST = 'localhost';
9+
const DEFAULT_BIND_IP_ALL = false;
910

1011
const argv = require('yargs')
1112
.option('port', {
@@ -18,6 +19,10 @@ const argv = require('yargs')
1819
type: 'string',
1920
desc: 'Hostname for the server to listen upon. Defaults to localhost.',
2021
})
22+
.option('bind_ip_all', {
23+
type: 'boolean',
24+
desc: 'Bind to all IPv4 and IPv6 addresses',
25+
})
2126
.example(
2227
'$0 -p 28200',
2328
'Start the OIDC mock identity provider server on port 28200'
@@ -41,6 +46,7 @@ const DEFAULT_TOKEN_PAYLOAD = {
4146
},
4247
port: argv.port ?? DEFAULT_PORT,
4348
hostname: argv.host ?? DEFAULT_HOST,
49+
bindIpAll: argv.bind_ip_all ?? DEFAULT_BIND_IP_ALL,
4450
};
4551
const mockIdentityProvider = await OIDCMockProvider.create(
4652
oidcMockProviderConfig

packages/oidc-mock-provider/src/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ export interface OIDCMockProviderConfig {
6060
*/
6161
hostname?: string;
6262

63+
/**
64+
* Optional bind to all IPv4 and IPv6 addresses.
65+
*/
66+
bindIpAll?: boolean;
67+
6368
/**
6469
* Optional additional fields to be returned when the OIDC configuration is accessed.
6570
*/
@@ -102,7 +107,10 @@ export class OIDCMockProvider {
102107
}
103108

104109
private async init(): Promise<this> {
105-
this.httpServer.listen(this.config.port ?? 0, this.config.hostname);
110+
this.httpServer.listen(
111+
this.config.port ?? 0,
112+
this.config.bindIpAll ? '::' : this.config.hostname
113+
);
106114
await once(this.httpServer, 'listening');
107115
const { port } = this.httpServer.address() as AddressInfo;
108116
this.issuer = `${

0 commit comments

Comments
 (0)