@feathersjs/authentication-jwt
Advanced tools
Comparing version 1.0.2 to 2.0.0
# Change Log | ||
## [v1.0.2](https://github.com/feathersjs/authentication-jwt/tree/v1.0.2) (2018-01-03) | ||
[Full Changelog](https://github.com/feathersjs/authentication-jwt/compare/v1.0.1...v1.0.2) | ||
**Closed issues:** | ||
- Include data into JWT response [\#47](https://github.com/feathersjs/authentication-jwt/issues/47) | ||
**Merged pull requests:** | ||
- Update documentation to correspond with latest release [\#51](https://github.com/feathersjs/authentication-jwt/pull/51) ([daffl](https://github.com/daffl)) | ||
- Update semistandard to the latest version 🚀 [\#50](https://github.com/feathersjs/authentication-jwt/pull/50) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) | ||
- Update feathers-memory to the latest version 🚀 [\#49](https://github.com/feathersjs/authentication-jwt/pull/49) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) | ||
## [v1.0.1](https://github.com/feathersjs/authentication-jwt/tree/v1.0.1) (2017-11-16) | ||
@@ -4,0 +17,0 @@ [Full Changelog](https://github.com/feathersjs/authentication-jwt/compare/v1.0.0...v1.0.1) |
@@ -34,7 +34,6 @@ const Debug = require('debug'); | ||
let authOptions = app.get('auth') || app.get('authentication') || {}; | ||
let jwtOptions = authOptions[options.name] || {}; | ||
const authOptions = app.get('auth') || app.get('authentication') || {}; | ||
const jwtOptions = authOptions[options.name] || {}; | ||
// NOTE (EK): Pull from global auth config to support legacy auth for an easier transition. | ||
let jwtSettings = merge({}, defaults, pick(authOptions, KEYS), jwtOptions, omit(options, ['Verifier'])); | ||
const jwtSettings = merge({}, defaults, pick(authOptions, KEYS), jwtOptions, omit(options, ['Verifier'])); | ||
@@ -45,4 +44,17 @@ if (typeof jwtSettings.header !== 'string') { | ||
if (typeof jwtSettings.secret === 'undefined') { | ||
throw new Error(`You must provide a 'secret' in your authentication configuration or pass one explicitly`); | ||
const extractors = [ | ||
ExtractJwt.fromAuthHeaderWithScheme('jwt'), | ||
ExtractJwt.fromAuthHeaderAsBearerToken(), | ||
ExtractJwt.fromHeader(jwtSettings.header.toLowerCase()), | ||
ExtractJwt.fromBodyField(jwtSettings.bodyKey) | ||
]; | ||
if (authOptions.cookie && authOptions.cookie.name) { | ||
extractors.push(function (req) { | ||
if (req && req.cookies) { | ||
return req.cookies[authOptions.cookie.name]; | ||
} | ||
return null; | ||
}); | ||
} | ||
@@ -53,8 +65,3 @@ | ||
secretOrKey: jwtSettings.secret, | ||
jwtFromRequest: ExtractJwt.fromExtractors([ | ||
ExtractJwt.fromAuthHeaderWithScheme('jwt'), | ||
ExtractJwt.fromAuthHeaderAsBearerToken(), | ||
ExtractJwt.fromHeader(jwtSettings.header.toLowerCase()), | ||
ExtractJwt.fromBodyField(jwtSettings.bodyKey) | ||
]) | ||
jwtFromRequest: ExtractJwt.fromExtractors(extractors) | ||
}, jwtSettings.jwt, omit(jwtSettings, ['jwt', 'header', 'secret'])); | ||
@@ -61,0 +68,0 @@ |
@@ -35,3 +35,3 @@ const Debug = require('debug'); | ||
debug(`Error populating ${this.options.entity} with id ${id}`, error); | ||
return done(null, {}, payload); | ||
return done(error); | ||
}); | ||
@@ -38,0 +38,0 @@ } |
{ | ||
"name": "@feathersjs/authentication-jwt", | ||
"description": "JWT authentication strategy for feathers-authentication using Passport", | ||
"version": "1.0.2", | ||
"version": "2.0.0", | ||
"homepage": "https://github.com/feathersjs/authentication-jwt", | ||
@@ -67,3 +67,3 @@ "main": "lib/", | ||
"jsonwebtoken": "^8.0.0", | ||
"mocha": "^4.0.0", | ||
"mocha": "^5.0.0", | ||
"semistandard": "^12.0.0", | ||
@@ -70,0 +70,0 @@ "sinon": "^4.0.0", |
17533
116