0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-03-17 22:31:28 -05:00

fix(core): bearerToken -> bearerTokenIdentifier

This commit is contained in:
Gao Sun 2021-08-25 23:40:19 +08:00
parent af11f18e40
commit a918a0ce8d
No known key found for this signature in database
GPG key ID: 0F0EFA2E36639F31

View file

@ -15,7 +15,7 @@ export type WithAuthContext<ContextT extends IRouterParamContext = IRouterParamC
user: UserInfo;
};
const bearerToken = 'Bearer';
const bearerTokenIdentifier = 'Bearer';
const extractBearerTokenFromHeaders = ({ authorization }: IncomingHttpHeaders) => {
assert(
@ -23,13 +23,13 @@ const extractBearerTokenFromHeaders = ({ authorization }: IncomingHttpHeaders) =
new RequestError({ code: 'auth.authorization_header_missing', status: 401 })
);
assert(
authorization.startsWith(bearerToken),
authorization.startsWith(bearerTokenIdentifier),
new RequestError(
{ code: 'auth.authorization_type_not_supported', status: 401 },
{ supportedTypes: [bearerToken] }
{ supportedTypes: [bearerTokenIdentifier] }
)
);
return authorization.slice(bearerToken.length + 1);
return authorization.slice(bearerTokenIdentifier.length + 1);
};
const getUserIdFromRequest = async (request: Request) => {