Skip to content

Commit c9f7f8f

Browse files
authored
Merge pull request #804 from MatrixAI/feature-eng-373-prevent-rpc-calls-for-unauthenticated-nodeconnections
Implementing network authentication and segregation logic to the nodes domain
2 parents 3f6f39a + 514f11a commit c9f7f8f

29 files changed

+1538
-129
lines changed

src/PolykeyAgent.ts

+8
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,14 @@ class PolykeyAgent {
386386
optionsDefaulted.nodes.connectionInitialMaxStreamsBidi,
387387
rpcParserBufferSize: optionsDefaulted.nodes.rpcParserBufferSize,
388388
rpcCallTimeoutTime: optionsDefaulted.nodes.rpcCallTimeoutTime,
389+
authenticateNetworkForwardCallback:
390+
nodesUtils.nodesAuthenticateConnectionForwardBasicPublicFactory(
391+
optionsDefaulted.network,
392+
),
393+
authenticateNetworkReverseCallback:
394+
nodesUtils.nodesAuthenticateConnectionReverseBasicPublicFactory(
395+
optionsDefaulted.network,
396+
),
389397
logger: logger.getChild(NodeConnectionManager.name),
390398
});
391399
nodeManager = new NodeManager({

src/client/ClientService.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ class ClientService {
3434
const conn = evt.detail;
3535
const streamHandler = (evt: wsEvents.EventWebSocketConnectionStream) => {
3636
const stream = evt.detail;
37+
// If the RPCServer is stopping or stopped then we want to reject new streams outright
3738
if (!this.rpcServer[running] || this.rpcServer[status] === 'stopping') {
38-
stream.cancel(Error('TMP RPCServer not running'));
39+
stream.cancel(new errors.ErrorClientServiceNotRunning());
3940
return;
4041
}
4142
this.rpcServer.handleStream(stream);

0 commit comments

Comments
 (0)