Skip to content

Commit 6c3eb5e

Browse files
authored
fix: only bind auth server to 127.0.0.1 (#4726)
* fix: only bind auth server to 127.0.0.1 Problem: - Auth server was being bound to all interfaces Solution: - Bind it only to 127.0.0.1
1 parent b1c9955 commit 6c3eb5e

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

packages/core/src/auth/sso/server.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export class AuthSSOServer {
107107
resolve()
108108
})
109109

110-
this.server.listen()
110+
this.server.listen(0, '127.0.0.1')
111111
})
112112
}
113113

@@ -134,8 +134,12 @@ export class AuthSSOServer {
134134
return `${this.baseUrl}:${this.getPort()}`
135135
}
136136

137+
public getAddress() {
138+
return this.server.address()
139+
}
140+
137141
private getPort(): number {
138-
const addr = this.server.address()
142+
const addr = this.getAddress()
139143
if (addr instanceof Object) {
140144
return addr.port
141145
} else if (typeof addr === 'string') {

packages/core/src/test/credentials/sso/server.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,13 @@ describe('AuthSSOServer', function () {
105105
const token = await server.waitForAuthorization()
106106
assert.deepStrictEqual(code, token)
107107
})
108+
109+
it('address is bound to localhost', function () {
110+
const address = server.getAddress()
111+
if (address instanceof Object) {
112+
assert.deepStrictEqual(address.address, '127.0.0.1')
113+
return
114+
}
115+
assert.fail('Expected address 127.0.0.1')
116+
})
108117
})

0 commit comments

Comments
 (0)