mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +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,
|
mcp as mcpMiddleware,
|
||||||
isNode,
|
isNode,
|
||||||
type McpServer,
|
type McpServer,
|
||||||
|
threw,
|
||||||
} from "bknd/utils";
|
} from "bknd/utils";
|
||||||
import type { Context, Hono } from "hono";
|
import type { Context, Hono } from "hono";
|
||||||
import { Controller } from "modules/Controller";
|
import { Controller } from "modules/Controller";
|
||||||
@@ -380,7 +381,11 @@ export class SystemController extends Controller {
|
|||||||
async (c) => {
|
async (c) => {
|
||||||
const module = c.req.param("module") as ModuleKey | undefined;
|
const module = c.req.param("module") as ModuleKey | undefined;
|
||||||
const { config, secrets, fresh } = c.req.valid("query");
|
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) {
|
if (config) {
|
||||||
this.ctx.guard.granted(SystemPermissions.configRead, c, {
|
this.ctx.guard.granted(SystemPermissions.configRead, c, {
|
||||||
|
|||||||
Reference in New Issue
Block a user