Skip to content

Commit

Permalink
BC-6453 - make jwt extraction more general
Browse files Browse the repository at this point in the history
  • Loading branch information
bergatco committed Jun 11, 2024
1 parent 7122174 commit 7d7f51c
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ export class AuthorizationClientAdapter {

private getJWT(): string {
const getJWT = ExtractJwt.fromExtractors([ExtractJwt.fromAuthHeaderAsBearerToken(), this.fromCookie('jwt')]);
const jwt = getJWT(this.request) || this.request.headers.authorization;
let jwt = getJWT(this.request) || this.request.headers.authorization;
if (jwt?.toLowerCase()?.startsWith('bearer ')) {
[, jwt] = jwt.split(' ');
}

if (!jwt) {
throw new UnauthorizedException('Authentication is required.');
Expand Down

0 comments on commit 7d7f51c

Please sign in to comment.