mirror of
https://github.com/HeyPuter/puter.git
synced 2026-10-07 04:12:36 +00: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:
1 parent
3f0e7659f3
commit
f6e6e8dff8
2 files changed
+33
No files matched your search
@@ -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 }) => {
|
||||
|
||||
@@ -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