Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/extract_jwt.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ extractors.fromAuthHeaderWithScheme = function (auth_scheme) {
if (request.headers[AUTH_HEADER]) {
var auth_params = auth_hdr.parse(request.headers[AUTH_HEADER]);
if (auth_params && auth_scheme_lower === auth_params.scheme.toLowerCase()) {
token = auth_params.value;
token = auth_params.value.endsWith(",")
? auth_params.value.split(",")[0]
: auth_params.value;
}
}
return token;
Expand Down
10 changes: 9 additions & 1 deletion test/extractors-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,16 @@ describe('Token extractor', function() {

expect(token).to.equal('abcd123');
});
});

it('should return the value from the authorization header without a comma at the end', function () {
var req = new Request()
req.headers['authorization'] = 'test_scheme abcd123,';

var token = extractor(req);

expect(token).to.equal('abcd123');
});
});

describe('fromAuthHeader', function() {

Expand Down