mirror of
https://github.com/HeyPuter/puter.git
synced 2026-01-04 20:20:50 -06:00
fix: shortcut KV permissions
All users have access to KV, however the permission system is used because: 1. KV is a driver, and all drivers have access checks 2. The rate limit policy comes from the permission system This change uses support for implicit permission shortcuts to prevent any of the permission association tables from being read. It also hard-codes the policy so that KV's rate-limit policy is not read from the policy.json file.
This commit is contained in:
@@ -394,6 +394,9 @@ const install = async ({ services, app, useapi, modapi }) => {
|
||||
|
||||
const { WorkerService } = require('./services/worker/WorkerService');
|
||||
services.registerService("worker-service", WorkerService)
|
||||
|
||||
const { PermissionShortcutService } = require('./services/auth/PermissionShortcutService');
|
||||
services.registerService('permission-shortcut', PermissionShortcutService);
|
||||
}
|
||||
|
||||
const install_legacy = async ({ services }) => {
|
||||
|
||||
30
src/backend/src/services/auth/PermissionShortcutService.js
Normal file
30
src/backend/src/services/auth/PermissionShortcutService.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const BaseService = require("../BaseService");
|
||||
const { PermissionImplicator } = require("./PermissionService");
|
||||
|
||||
class PermissionShortcutService extends BaseService {
|
||||
_init () {
|
||||
const svc_permission = this.services.get('permission');
|
||||
|
||||
svc_permission.register_implicator(PermissionImplicator.create({
|
||||
id: 'kv permissions are easy',
|
||||
shortcut: true,
|
||||
matcher: permission => {
|
||||
return permission === 'service:puter-kvstore:ii:puter-kvstore';
|
||||
},
|
||||
checker: async ({ actor }) => {
|
||||
return {
|
||||
policy: {
|
||||
"rate-limit": {
|
||||
max: 3000,
|
||||
period: 30000,
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
PermissionShortcutService,
|
||||
};
|
||||
Reference in New Issue
Block a user