Skip to content

Commit

Permalink
fix(api-server): allow no authorization on socketio endpoints
Browse files Browse the repository at this point in the history
authorizeSocket middleware will be installed only if
AuthorizationProtocol different than NONE was provided.

Closes:  hyperledger-cacti#1925
Signed-off-by: Michal Bajer <michal.bajer@fujitsu.com>
  • Loading branch information
outSH authored and petermetz committed Mar 21, 2022
1 parent 80a8e0a commit 310ce6a
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions packages/cactus-cmd-api-server/src/main/typescript/api-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -732,14 +732,15 @@ export class ApiServer {

this.wsApi.attach(this.httpServerApi, wsOptions);

const socketIoAuthorizer = authorizeSocket({
...authzConf.socketIoJwtOptions,
onAuthentication: (decodedToken) => {
this.log.debug("Socket authorized OK: %o", decodedToken);
},
});

this.wsApi.use(socketIoAuthorizer as never);
if (authorizerO.isPresent()) {
const socketIoAuthorizer = authorizeSocket({
...authzConf.socketIoJwtOptions,
onAuthentication: (decodedToken) => {
this.log.debug("Socket authorized OK: %o", decodedToken);
},
});
this.wsApi.use(socketIoAuthorizer as never);
}

return addressInfo;
}
Expand Down

0 comments on commit 310ce6a

Please sign in to comment.