Skip to content
This repository was archived by the owner on Aug 29, 2018. It is now read-only.

Commit 0026878

Browse files
authoredDec 14, 2016
Merge pull request #6 from timelesshaze/fix-auth-header
Add support for using the Bearer scheme in the Auth header
2 parents 0dd0c65 + 5aaa515 commit 0026878

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
 

‎src/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export default function init (options = {}) {
4848
let strategyOptions = merge({
4949
secretOrKey: jwtSettings.secret,
5050
jwtFromRequest: ExtractJwt.fromExtractors([
51+
ExtractJwt.fromAuthHeaderWithScheme('Bearer'),
5152
ExtractJwt.fromHeader(jwtSettings.header.toLowerCase()),
5253
ExtractJwt.fromBodyField(jwtSettings.bodyKey)
5354
])

‎test/index.test.js

+20
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,26 @@ describe('feathers-authentication-jwt', () => {
189189
passportJWT.Strategy.restore();
190190
});
191191

192+
describe('Bearer scheme', () => {
193+
it('authenticates using the default verifier', () => {
194+
const req = {
195+
query: {},
196+
body: {},
197+
headers: {
198+
authorization: `Bearer ${validToken}`
199+
},
200+
cookies: {}
201+
};
202+
203+
app.configure(jwt());
204+
app.setup();
205+
206+
return app.authenticate('jwt', { assignProperty: 'payload' })(req).then(result => {
207+
expect(result.success).to.equal(true);
208+
});
209+
});
210+
});
211+
192212
describe('custom Verifier', () => {
193213
it('throws an error if a verify function is missing', () => {
194214
expect(() => {

0 commit comments

Comments
 (0)