Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(server): remove requirement of authentication for customRequestHandler
Elian Doran24ac85f40b1e
diff --git a/apps/server/src/routes/custom.spec.ts b/apps/server/src/routes/custom.spec.tsindex 3af8d304fe..ab6869f85a 100644--- a/apps/server/src/routes/custom.spec.ts+++ b/apps/server/src/routes/custom.spec.ts@@ -31,8 +31,6 @@ describe("Custom request/resource handlers", () => {content: `api.res.status(200).send("handled:" + api.pathParams[0]);`}).note;handler.setLabel("customRequestHandler", "greet/([a-z]+)");- // Public so the unauthenticated supertest request isn't rejected with 401.- handler.setLabel("customRequestHandlerPublic");// A script note that throws, to exercise the error branch.const thrower = noteService.createNewNote({@@ -43,7 +41,6 @@ describe("Custom request/resource handlers", () => {content: `throw new Error("boom in handler");`}).note;thrower.setLabel("customRequestHandler", "explode");- thrower.setLabel("customRequestHandlerPublic");// A resource note served directly.const resource = noteService.createNewNote({diff --git a/apps/server/src/routes/custom.ts b/apps/server/src/routes/custom.tsindex 8a20086040..bb93b27325 100644--- a/apps/server/src/routes/custom.ts+++ b/apps/server/src/routes/custom.ts@@ -67,14 +67,6 @@ function handleRequest(req: Request, res: Response) {if (attr.name === "customRequestHandler") {const note = attr.getNote();- // Require authentication unless note has #customRequestHandlerPublic label- if (!note.hasLabel("customRequestHandlerPublic")) {- if (!req.session?.loggedIn) {- res.status(401).send("Authentication required for this endpoint.");- return;- }- }-getLog().info(`Handling custom request '${path}' with note '${note.noteId}'`);try {diff --git a/packages/commons/src/lib/builtin_attributes.ts b/packages/commons/src/lib/builtin_attributes.tsindex 4038752845..b124b7a492 100644--- a/packages/commons/src/lib/builtin_attributes.ts+++ b/packages/commons/src/lib/builtin_attributes.ts@@ -19,7 +19,6 @@ export default [{ type: "label", name: "runOnInstance", isDangerous: false },{ type: "label", name: "runAtHour", isDangerous: false },{ type: "label", name: "customRequestHandler", isDangerous: true },- { type: "label", name: "customRequestHandlerPublic", isDangerous: true },{ type: "label", name: "customResourceProvider", isDangerous: true },{ type: "label", name: "widget", isDangerous: true },{ type: "label", name: "noteInfoWidgetDisabled" },