From afa4d55c0541163617b2cb7da6e192ad9766073e Mon Sep 17 00:00:00 2001 From: David Luecke Date: Tue, 23 Apr 2019 19:35:21 -0700 Subject: [PATCH] fix: Merge httpStrategies and authStrategies option (#1308) --- .../authentication-client/test/integration/fixture.ts | 1 - packages/authentication-local/test/fixture.js | 1 - packages/authentication-oauth/test/fixture.ts | 2 +- packages/authentication/src/options.ts | 1 - packages/express/lib/authentication.js | 8 ++++---- packages/express/test/authentication.test.js | 6 +++--- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/packages/authentication-client/test/integration/fixture.ts b/packages/authentication-client/test/integration/fixture.ts index 627e642e6..ddc32c219 100644 --- a/packages/authentication-client/test/integration/fixture.ts +++ b/packages/authentication-client/test/integration/fixture.ts @@ -14,7 +14,6 @@ export default (app: Application) => { entity: 'user', service: 'users', secret: 'supersecret', - httpStrategies: [ 'jwt' ], authStrategies: [ 'local', 'jwt' ], local: { usernameField: 'email', diff --git a/packages/authentication-local/test/fixture.js b/packages/authentication-local/test/fixture.js index c3cfb32c3..411cef1ee 100644 --- a/packages/authentication-local/test/fixture.js +++ b/packages/authentication-local/test/fixture.js @@ -13,7 +13,6 @@ module.exports = (app = feathers()) => { service: 'users', secret: 'supersecret', authStrategies: [ 'local', 'jwt' ], - httpStrategies: [ 'jwt' ], local: { usernameField: 'email', passwordField: 'password' diff --git a/packages/authentication-oauth/test/fixture.ts b/packages/authentication-oauth/test/fixture.ts index bffc920c8..a10dc540d 100644 --- a/packages/authentication-oauth/test/fixture.ts +++ b/packages/authentication-oauth/test/fixture.ts @@ -30,7 +30,7 @@ app.set('authentication', { secret: 'supersecret', entity: 'user', service: 'users', - httpStrategies: [ 'jwt' ], + authStrategies: [ 'jwt' ], oauth: { defaults: { transport: 'query' diff --git a/packages/authentication/src/options.ts b/packages/authentication/src/options.ts index 1042e9a5d..ee869f2b0 100644 --- a/packages/authentication/src/options.ts +++ b/packages/authentication/src/options.ts @@ -1,5 +1,4 @@ export default { - httpStrategies: [], authStrategies: [], jwtOptions: { header: { typ: 'access' }, // by default is an access token but can be any type diff --git a/packages/express/lib/authentication.js b/packages/express/lib/authentication.js index ec99d7b66..2728f2bf9 100644 --- a/packages/express/lib/authentication.js +++ b/packages/express/lib/authentication.js @@ -24,14 +24,14 @@ exports.parseAuthentication = (settings = {}) => { return next(); } - const { httpStrategies = [] } = service.configuration; + const { authStrategies = [] } = service.configuration; - if (httpStrategies.length === 0) { - debug('No `httpStrategies` found in authentication configuration'); + if (authStrategies.length === 0) { + debug('No `authStrategies` found in authentication configuration'); return next(); } - service.parse(req, res, ...httpStrategies) + service.parse(req, res, ...authStrategies) .then(authentication => { debug('Parsed authentication from HTTP header', authentication); merge(req, { diff --git a/packages/express/test/authentication.test.js b/packages/express/test/authentication.test.js index 4d2f3ab52..270e163f0 100644 --- a/packages/express/test/authentication.test.js +++ b/packages/express/test/authentication.test.js @@ -116,9 +116,9 @@ describe('@feathersjs/express/authentication', () => { }); }); - it('errors when there are no httpStrategies', () => { + it('errors when there are no authStrategies', () => { const { accessToken } = authResult; - app.get('authentication').httpStrategies = []; + app.get('authentication').authStrategies = []; return axios.get('/dummy/dave', { headers: { @@ -127,7 +127,7 @@ describe('@feathersjs/express/authentication', () => { }).then(() => assert.fail('Should never get here')) .catch(error => { assert.strictEqual(error.response.data.name, 'NotAuthenticated'); - app.get('authentication').httpStrategies = [ 'jwt' ]; + app.get('authentication').authStrategies = [ 'jwt', 'local' ]; }); });