mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-15 20:17:22 +00:00
Enhance SystemController to improve config modification checks
Updated the `SystemController` to include additional checks for read-only status and user permissions when modifying configurations.
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
||||
mcp as mcpMiddleware,
|
||||
isNode,
|
||||
type McpServer,
|
||||
threw,
|
||||
} from "bknd/utils";
|
||||
import type { Context, Hono } from "hono";
|
||||
import { Controller } from "modules/Controller";
|
||||
@@ -380,7 +381,11 @@ export class SystemController extends Controller {
|
||||
async (c) => {
|
||||
const module = c.req.param("module") as ModuleKey | undefined;
|
||||
const { config, secrets, fresh } = c.req.valid("query");
|
||||
const readonly = this.app.isReadOnly();
|
||||
const readonly =
|
||||
// either if app is read only in general
|
||||
this.app.isReadOnly() ||
|
||||
// or if user is not allowed to modify the config
|
||||
threw(() => this.ctx.guard.granted(SystemPermissions.configWrite, c, { module }));
|
||||
|
||||
if (config) {
|
||||
this.ctx.guard.granted(SystemPermissions.configRead, c, {
|
||||
|
||||
Reference in New Issue
Block a user