Skip to content

Commit f8a8be2

Browse files
committed
client-replica: add permission check (whitelist)
1 parent a2ee91f commit f8a8be2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/backend/src/routers/filesystem_api/fs_tree_manager/fetch_replica.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,23 @@
1919

2020
'use strict';
2121

22+
const { Context } = require('../../../../util/context');
23+
2224
// -----------------------------------------------------------------------//
2325
// WebSocket handler for replica/fetch
2426
// -----------------------------------------------------------------------//
2527
module.exports = {
2628
event: 'replica/fetch',
2729
handler: async (socket, _data) => {
30+
const svc_permission = Context.get('services').get('permission');
31+
const can_access = await svc_permission.check('endpoint:replica/fetch');
32+
if ( ! can_access ) {
33+
return socket.emit('replica/fetch/error', {
34+
success: false,
35+
error: { message: 'permission denied' },
36+
});
37+
}
38+
2839
// Import gRPC client and protobuf classes from common
2940
const {
3041
getClient,

0 commit comments

Comments
 (0)