This repository was archived by the owner on Aug 29, 2018. It is now read-only.
File tree 2 files changed +21
-0
lines changed
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ export default function init (options = {}) {
48
48
let strategyOptions = merge ( {
49
49
secretOrKey : jwtSettings . secret ,
50
50
jwtFromRequest : ExtractJwt . fromExtractors ( [
51
+ ExtractJwt . fromAuthHeaderWithScheme ( 'Bearer' ) ,
51
52
ExtractJwt . fromHeader ( jwtSettings . header . toLowerCase ( ) ) ,
52
53
ExtractJwt . fromBodyField ( jwtSettings . bodyKey )
53
54
] )
Original file line number Diff line number Diff line change @@ -189,6 +189,26 @@ describe('feathers-authentication-jwt', () => {
189
189
passportJWT . Strategy . restore ( ) ;
190
190
} ) ;
191
191
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
+
192
212
describe ( 'custom Verifier' , ( ) => {
193
213
it ( 'throws an error if a verify function is missing' , ( ) => {
194
214
expect ( ( ) => {
You can’t perform that action at this time.
0 commit comments