From 4121597fa2e4e0a6a61a179bdd54663b5273b02a Mon Sep 17 00:00:00 2001 From: Jonas Perusquia Morales Date: Tue, 24 Mar 2026 12:20:17 -0600 Subject: [PATCH] fix: Match Bearer case-insensitively and trim whitespace(s) --- app/src/Api.ts | 2 +- app/src/auth/authenticate/Authenticator.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/Api.ts b/app/src/Api.ts index adf69e6e..515d5ace 100644 --- a/app/src/Api.ts +++ b/app/src/Api.ts @@ -121,7 +121,7 @@ export class Api { } // try authorization header - const headerToken = this.options.headers.get("authorization")?.replace("Bearer ", ""); + const headerToken = this.options.headers.get("authorization")?.replace(/^Bearer\s+/i, ""); if (headerToken) { this.token_transport = "header"; this.updateToken(headerToken); diff --git a/app/src/auth/authenticate/Authenticator.ts b/app/src/auth/authenticate/Authenticator.ts index 03f13e9e..d0cb083f 100644 --- a/app/src/auth/authenticate/Authenticator.ts +++ b/app/src/auth/authenticate/Authenticator.ts @@ -430,7 +430,7 @@ export class Authenticator< let token: string | undefined; if (headers.has("Authorization")) { const bearerHeader = String(headers.get("Authorization")); - token = bearerHeader.replace("Bearer ", ""); + token = bearerHeader.replace(/^Bearer\s+/i, ""); } else { const context = is_context ? (c as Context) : ({ req: { raw: { headers } } } as Context); token = await this.getAuthCookie(context);