From 18ce292d898a5629df7a69b09e2f400bde01b871 Mon Sep 17 00:00:00 2001 From: yaroslav8765 Date: Mon, 6 Oct 2025 17:05:16 +0300 Subject: [PATCH 01/43] fix: remove "npm version patch" from package.json template in create plugin command --- adminforth/commands/createPlugin/templates/package.json.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adminforth/commands/createPlugin/templates/package.json.hbs b/adminforth/commands/createPlugin/templates/package.json.hbs index d46c1e5af..42b3f687f 100644 --- a/adminforth/commands/createPlugin/templates/package.json.hbs +++ b/adminforth/commands/createPlugin/templates/package.json.hbs @@ -5,7 +5,7 @@ "types": "dist/index.d.ts", "type": "module", "scripts": { - "build": "tsc && rsync -av --exclude 'node_modules' custom dist/ && npm version patch" + "build": "tsc && rsync -av --exclude 'node_modules' custom dist/" }, "keywords": [], "author": "", From 22d495986e8690d00ec8e1766fa01485091ec1e0 Mon Sep 17 00:00:00 2001 From: yaroslav8765 Date: Mon, 6 Oct 2025 17:11:11 +0300 Subject: [PATCH 02/43] docs: update example for passkeys in TwoFactorAuth --- .../docs/tutorial/07-Plugins/02-TwoFactorsAuth.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/adminforth/documentation/docs/tutorial/07-Plugins/02-TwoFactorsAuth.md b/adminforth/documentation/docs/tutorial/07-Plugins/02-TwoFactorsAuth.md index ae4454f53..ed0b5e42c 100644 --- a/adminforth/documentation/docs/tutorial/07-Plugins/02-TwoFactorsAuth.md +++ b/adminforth/documentation/docs/tutorial/07-Plugins/02-TwoFactorsAuth.md @@ -303,7 +303,7 @@ Now, update the settings of the Two-Factor Authentication plugin: plugins: [ new TwoFactorsAuthPlugin ({ twoFaSecretFieldName: 'secret2fa', - timeStepWindow: 1 + timeStepWindow: 1, //diff-add passkeys: { //diff-add @@ -317,7 +317,7 @@ Now, update the settings of the Two-Factor Authentication plugin: //diff-add settings: { // diff-add - expectedOrigin: "http://localhost:3000", // important, set it to your backoffice origin (starts from scheme, no slash at the end) + expectedOrigin: "http://localhost:3500", // important, set it to your backoffice origin (starts from scheme, no slash at the end) //diff-add // relying party config //diff-add @@ -352,7 +352,7 @@ Now, update the settings of the Two-Factor Authentication plugin: // diff-add // Can be "platform", "cross-platform" or "both" // diff-add - authenticatorAttachment: "platform", + authenticatorAttachment: "both", //diff-add requireResidentKey: true, //diff-add From 0ca5f6b3bfd4e9a8da33ce7004dc01f60eff1335 Mon Sep 17 00:00:00 2001 From: Ivan Borshchov Date: Mon, 6 Oct 2025 19:25:29 +0000 Subject: [PATCH 03/43] feat: enforce JSON-only content type for mutation methods in ExpressServer --- adminforth/servers/express.ts | 13 +++++++++++++ adminforth/spa/src/utils.ts | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/adminforth/servers/express.ts b/adminforth/servers/express.ts index ac1e70cbb..b8e38b8d1 100644 --- a/adminforth/servers/express.ts +++ b/adminforth/servers/express.ts @@ -269,6 +269,19 @@ class ExpressServer implements IExpressHttpServer { const fullPath = `${this.adminforth.config.baseUrl}/adminapi/v1${path}`; const expressHandler = async (req, res) => { + // Enforce JSON-only for mutation HTTP methods + // AdminForth API endpoints accept only application/json for POST, PUT, PATCH, DELETE + // If you need other content types, use a custom server endpoint. + const method = (req.method || '').toUpperCase(); + if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) { + const contentTypeHeader = (req.headers?.['content-type'] || '').toString(); + const isJson = contentTypeHeader.toLowerCase().startsWith('application/json'); + if (!isJson) { + const passed = contentTypeHeader || 'undefined'; + res.status(415).send(`AdminForth API endpoints support only requests with Content/Type: application/json, when you passed: ${passed}. Please use custom server endpoint if you really need this content type`); + return; + } + } let body = req.body || {}; if (typeof body === 'string') { try { diff --git a/adminforth/spa/src/utils.ts b/adminforth/spa/src/utils.ts index ba3c1c51a..eef5bf86f 100644 --- a/adminforth/spa/src/utils.ts +++ b/adminforth/spa/src/utils.ts @@ -50,7 +50,7 @@ export async function callApi({path, method, body=undefined}: { export async function callAdminForthApi({ path, method, body=undefined, headers=undefined }: { path: string, - method: 'GET' | 'POST' | 'PUT' | 'DELETE', + method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH', body?: any, headers?: Record }): Promise { From 6406840c01bca96cff68536cdd24979a9807d9ec Mon Sep 17 00:00:00 2001 From: yaroslav8765 Date: Tue, 7 Oct 2025 08:47:57 +0300 Subject: [PATCH 04/43] fix: adjust margin for settings view template --- adminforth/spa/src/views/SettingsView.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adminforth/spa/src/views/SettingsView.vue b/adminforth/spa/src/views/SettingsView.vue index 704833de9..92e87f3e6 100644 --- a/adminforth/spa/src/views/SettingsView.vue +++ b/adminforth/spa/src/views/SettingsView.vue @@ -1,5 +1,5 @@