Skip to content

Commit

Permalink
fix: Merge httpStrategies and authStrategies option (#1308)
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl committed Apr 24, 2019
1 parent 12d48ee commit afa4d55
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 11 deletions.
1 change: 0 additions & 1 deletion packages/authentication-client/test/integration/fixture.ts
Expand Up @@ -14,7 +14,6 @@ export default (app: Application) => {
entity: 'user',
service: 'users',
secret: 'supersecret',
httpStrategies: [ 'jwt' ],
authStrategies: [ 'local', 'jwt' ],
local: {
usernameField: 'email',
Expand Down
1 change: 0 additions & 1 deletion packages/authentication-local/test/fixture.js
Expand Up @@ -13,7 +13,6 @@ module.exports = (app = feathers()) => {
service: 'users',
secret: 'supersecret',
authStrategies: [ 'local', 'jwt' ],
httpStrategies: [ 'jwt' ],
local: {
usernameField: 'email',
passwordField: 'password'
Expand Down
2 changes: 1 addition & 1 deletion packages/authentication-oauth/test/fixture.ts
Expand Up @@ -30,7 +30,7 @@ app.set('authentication', {
secret: 'supersecret',
entity: 'user',
service: 'users',
httpStrategies: [ 'jwt' ],
authStrategies: [ 'jwt' ],
oauth: {
defaults: {
transport: 'query'
Expand Down
1 change: 0 additions & 1 deletion 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
Expand Down
8 changes: 4 additions & 4 deletions packages/express/lib/authentication.js
Expand Up @@ -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, {
Expand Down
6 changes: 3 additions & 3 deletions packages/express/test/authentication.test.js
Expand Up @@ -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: {
Expand All @@ -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' ];
});
});

Expand Down

0 comments on commit afa4d55

Please sign in to comment.