diff --git a/lib/handlers/authenticate-handler.ts b/lib/handlers/authenticate-handler.ts index 67b30b0a1..dff2edea0 100755 --- a/lib/handlers/authenticate-handler.ts +++ b/lib/handlers/authenticate-handler.ts @@ -145,7 +145,7 @@ export class AuthenticateHandler { getTokenFromRequestHeader(request: Request) { const token = request.get('Authorization'); - const matches = token.match(/Bearer\s(\S+)/); + const matches = token.match(/^Bearer\s(\S+)/); if (!matches) { throw new InvalidRequestError( diff --git a/test/integration/handlers/authenticate-handler.spec.ts b/test/integration/handlers/authenticate-handler.spec.ts index 9200e9d01..201658a18 100755 --- a/test/integration/handlers/authenticate-handler.spec.ts +++ b/test/integration/handlers/authenticate-handler.spec.ts @@ -303,7 +303,7 @@ describe('AuthenticateHandler integration', () => { const request = new Request({ body: {}, headers: { - Authorization: 'foobar', + Authorization: 'foo Bearer bar', }, method: 'ANY', query: {},