Skip to content

Commit

Permalink
Merge with latest master
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl committed May 1, 2020
2 parents 5538881 + 98027c4 commit be85b23
Show file tree
Hide file tree
Showing 37 changed files with 359 additions and 83 deletions.
27 changes: 27 additions & 0 deletions changelog.md
Expand Up @@ -3,6 +3,33 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [4.5.4](https://github.com/feathersjs/feathers/compare/v4.5.3...v4.5.4) (2020-04-29)


### Bug Fixes

* **authentication-local:** Allow to hash passwords in array data ([#1936](https://github.com/feathersjs/feathers/issues/1936)) ([64705f5](https://github.com/feathersjs/feathers/commit/64705f5d9d4dc27f799da3a074efaf74379a3398))
* **authentication-oauth:** Add getEntity method to oAuth authentication and remove provider field for other calls ([#1935](https://github.com/feathersjs/feathers/issues/1935)) ([d925c1b](https://github.com/feathersjs/feathers/commit/d925c1bd193b5c19cb23a246f04fc46d0429fc75))





## [4.5.3](https://github.com/feathersjs/feathers/compare/v4.5.2...v4.5.3) (2020-04-17)


### Bug Fixes

* **authentication:** Remove entity from connection information on logout ([#1889](https://github.com/feathersjs/feathers/issues/1889)) ([b062753](https://github.com/feathersjs/feathers/commit/b0627530d61babe15dd84369d3093ccae4b780ca))
* **authentication-oauth:** Allow req.feathers to be used in oAuth authentication requests ([#1886](https://github.com/feathersjs/feathers/issues/1886)) ([854c9ca](https://github.com/feathersjs/feathers/commit/854c9cac9a9a5f8f89054a90feb24ab5c4766f5f))
* **errors:** Add 410 Gone to errors ([#1849](https://github.com/feathersjs/feathers/issues/1849)) ([6801428](https://github.com/feathersjs/feathers/commit/6801428f8fd17dbfebcdb6f1b0cd01433a4033dc))
* **typescript:** Add type keys to service pagination options. ([#1888](https://github.com/feathersjs/feathers/issues/1888)) ([859c601](https://github.com/feathersjs/feathers/commit/859c601519c7cb399e8b1667bb50073466812d5c))
* **typescript:** Use stricter type for HookContext 'method' prop ([#1896](https://github.com/feathersjs/feathers/issues/1896)) ([24a41b7](https://github.com/feathersjs/feathers/commit/24a41b74486ddadccad18f3ae63afdac5bd373c7))





## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04)


Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Expand Up @@ -3,7 +3,7 @@
"packages": [
"packages/*"
],
"version": "4.5.2",
"version": "4.5.4",
"command": {
"bootstrap": {
"hoist": true
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions packages/authentication-client/CHANGELOG.md
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [4.5.4](https://github.com/feathersjs/feathers/compare/v4.5.3...v4.5.4) (2020-04-29)

**Note:** Version bump only for package @feathersjs/authentication-client





## [4.5.3](https://github.com/feathersjs/feathers/compare/v4.5.2...v4.5.3) (2020-04-17)

**Note:** Version bump only for package @feathersjs/authentication-client





## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04)

**Note:** Version bump only for package @feathersjs/authentication-client
Expand Down
20 changes: 10 additions & 10 deletions packages/authentication-client/package.json
@@ -1,7 +1,7 @@
{
"name": "@feathersjs/authentication-client",
"description": "The authentication plugin for feathers-client",
"version": "4.5.2",
"version": "4.5.4",
"homepage": "https://feathersjs.com",
"main": "lib/",
"types": "lib/",
Expand Down Expand Up @@ -43,18 +43,18 @@
"access": "public"
},
"dependencies": {
"@feathersjs/authentication": "^4.5.2",
"@feathersjs/commons": "^4.5.2",
"@feathersjs/errors": "^4.5.2",
"@feathersjs/feathers": "^4.5.2",
"@feathersjs/authentication": "^4.5.3",
"@feathersjs/commons": "^4.5.3",
"@feathersjs/errors": "^4.5.3",
"@feathersjs/feathers": "^4.5.3",
"debug": "^4.1.1"
},
"devDependencies": {
"@feathersjs/authentication-local": "^4.5.2",
"@feathersjs/express": "^4.5.2",
"@feathersjs/rest-client": "^4.5.2",
"@feathersjs/socketio": "^4.5.2",
"@feathersjs/socketio-client": "^4.5.2",
"@feathersjs/authentication-local": "^4.5.4",
"@feathersjs/express": "^4.5.4",
"@feathersjs/rest-client": "^4.5.4",
"@feathersjs/socketio": "^4.5.4",
"@feathersjs/socketio-client": "^4.5.4",
"@types/debug": "^4.1.5",
"@types/mocha": "^7.0.2",
"@types/node": "^13.11.1",
Expand Down
19 changes: 19 additions & 0 deletions packages/authentication-local/CHANGELOG.md
Expand Up @@ -3,6 +3,25 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [4.5.4](https://github.com/feathersjs/feathers/compare/v4.5.3...v4.5.4) (2020-04-29)


### Bug Fixes

* **authentication-local:** Allow to hash passwords in array data ([#1936](https://github.com/feathersjs/feathers/issues/1936)) ([64705f5](https://github.com/feathersjs/feathers/commit/64705f5d9d4dc27f799da3a074efaf74379a3398))





## [4.5.3](https://github.com/feathersjs/feathers/compare/v4.5.2...v4.5.3) (2020-04-17)

**Note:** Version bump only for package @feathersjs/authentication-local





## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04)


Expand Down
8 changes: 4 additions & 4 deletions packages/authentication-local/package.json
@@ -1,7 +1,7 @@
{
"name": "@feathersjs/authentication-local",
"description": "Local authentication strategy for @feathers/authentication",
"version": "4.5.2",
"version": "4.5.4",
"homepage": "https://feathersjs.com",
"main": "lib/",
"types": "lib/",
Expand Down Expand Up @@ -43,9 +43,9 @@
"access": "public"
},
"dependencies": {
"@feathersjs/authentication": "^4.5.2",
"@feathersjs/errors": "^4.5.2",
"@feathersjs/feathers": "^4.5.2",
"@feathersjs/authentication": "^4.5.3",
"@feathersjs/errors": "^4.5.3",
"@feathersjs/feathers": "^4.5.3",
"bcryptjs": "^2.4.3",
"debug": "^4.1.1",
"lodash": "^4.17.15"
Expand Down
21 changes: 16 additions & 5 deletions packages/authentication-local/src/hooks/hash-password.ts
Expand Up @@ -24,10 +24,9 @@ export default function hashPassword (field: string, options: HashPasswordOption
}

const { app, data, params } = context;
const password = get(data, field);

if (data === undefined || password === undefined) {
debug(`hook.data or hook.data.${field} is undefined. Skipping hashPassword hook.`);
if (data === undefined) {
debug(`hook.data is undefined. Skipping hashPassword hook.`);
return context;
}

Expand All @@ -44,9 +43,21 @@ export default function hashPassword (field: string, options: HashPasswordOption
throw new BadRequest(`Could not find '${strategy}' strategy to hash password`);
}

const hashedPassword: string = await localStrategy.hashPassword(password, params);
const addHashedPassword = async (data: any) => {
const password = get(data, field);

context.data = set(cloneDeep(data), field, hashedPassword);
if (password === undefined) {
debug(`hook.data.${field} is undefined, not hashing password`);
return data;
}

const hashedPassword: string = await localStrategy.hashPassword(password, params);

return set(cloneDeep(data), field, hashedPassword);
}

context.data = Array.isArray(data) ? await Promise.all(data.map(addHashedPassword)) :
await addHashedPassword(data);

return context;
};
Expand Down
1 change: 1 addition & 0 deletions packages/authentication-local/test/fixture.js
Expand Up @@ -25,6 +25,7 @@ module.exports = (app = feathers()) => {

app.use('/authentication', authentication);
app.use('/users', memory({
multi: [ 'create' ],
paginate: {
default: 10,
max: 20
Expand Down
15 changes: 15 additions & 0 deletions packages/authentication-local/test/hooks/hash-password.test.ts
Expand Up @@ -89,6 +89,21 @@ describe('@feathersjs/authentication-local/hooks/hash-password', () => {
assert.notStrictEqual(user.password, password);
});

it('hashes password on array data', async () => {
const password = 'supersecret';

const users = await app.service('users').create([{
email: 'dave@hashpassword.com',
password
}, {
email: 'dave2@hashpassword.com',
password: 'secret2'
}]);

assert.notStrictEqual(users[0].password, password);
assert.notStrictEqual(users[1].password, 'secret2');
});

it('does nothing when field is not present', async () => {
const user = await app.service('users').create({
email: 'dave@hashpassword.com'
Expand Down
22 changes: 22 additions & 0 deletions packages/authentication-oauth/CHANGELOG.md
Expand Up @@ -3,6 +3,28 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [4.5.4](https://github.com/feathersjs/feathers/compare/v4.5.3...v4.5.4) (2020-04-29)


### Bug Fixes

* **authentication-oauth:** Add getEntity method to oAuth authentication and remove provider field for other calls ([#1935](https://github.com/feathersjs/feathers/issues/1935)) ([d925c1b](https://github.com/feathersjs/feathers/commit/d925c1bd193b5c19cb23a246f04fc46d0429fc75))





## [4.5.3](https://github.com/feathersjs/feathers/compare/v4.5.2...v4.5.3) (2020-04-17)


### Bug Fixes

* **authentication-oauth:** Allow req.feathers to be used in oAuth authentication requests ([#1886](https://github.com/feathersjs/feathers/issues/1886)) ([854c9ca](https://github.com/feathersjs/feathers/commit/854c9cac9a9a5f8f89054a90feb24ab5c4766f5f))





## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04)


Expand Down
10 changes: 5 additions & 5 deletions packages/authentication-oauth/package.json
@@ -1,7 +1,7 @@
{
"name": "@feathersjs/authentication-oauth",
"description": "oAuth 1 and 2 authentication for Feathers. Powered by Grant.",
"version": "4.5.2",
"version": "4.5.4",
"homepage": "https://feathersjs.com",
"main": "lib/",
"types": "lib/",
Expand Down Expand Up @@ -43,10 +43,10 @@
"access": "public"
},
"dependencies": {
"@feathersjs/authentication": "^4.5.2",
"@feathersjs/errors": "^4.5.2",
"@feathersjs/express": "^4.5.2",
"@feathersjs/feathers": "^4.5.2",
"@feathersjs/authentication": "^4.5.3",
"@feathersjs/errors": "^4.5.3",
"@feathersjs/express": "^4.5.4",
"@feathersjs/feathers": "^4.5.3",
"debug": "^4.1.1",
"express-session": "^1.17.0",
"grant": "^4.7.0",
Expand Down
24 changes: 22 additions & 2 deletions packages/authentication-oauth/src/strategy.ts
Expand Up @@ -6,6 +6,7 @@ import {
AuthenticationRequest, AuthenticationBaseStrategy, AuthenticationResult
} from '@feathersjs/authentication';
import { Params } from '@feathersjs/feathers';
import { NotAuthenticated } from '@feathersjs/errors';

const debug = Debug('@feathersjs/authentication-oauth/strategy');

Expand Down Expand Up @@ -126,8 +127,27 @@ export class OAuthStrategy extends AuthenticationBaseStrategy {
return this.entityService.patch(id, data, params);
}

async authenticate (authentication: AuthenticationRequest, params: Params) {
async getEntity (result: any, params: Params) {
const { entityService } = this;
const { entityId = entityService.id, entity } = this.configuration;

if (!entityId || result[entityId] === undefined) {
throw new NotAuthenticated('Could not get oAuth entity');
}

if (!params.provider) {
return result;
}

return entityService.get(result[entityId], {
...params,
[entity]: result
});
}

async authenticate (authentication: AuthenticationRequest, originalParams: Params) {
const entity: string = this.configuration.entity;
const { provider, ...params } = originalParams;
const profile = await this.getProfile(authentication, params);
const existingEntity = await this.findEntity(profile, params)
|| await this.getCurrentEntity(params);
Expand All @@ -139,7 +159,7 @@ export class OAuthStrategy extends AuthenticationBaseStrategy {

return {
authentication: { strategy: this.name },
[entity]: authEntity
[entity]: await this.getEntity(authEntity, originalParams)
};
}
}
11 changes: 11 additions & 0 deletions packages/authentication/CHANGELOG.md
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [4.5.3](https://github.com/feathersjs/feathers/compare/v4.5.2...v4.5.3) (2020-04-17)


### Bug Fixes

* **authentication:** Remove entity from connection information on logout ([#1889](https://github.com/feathersjs/feathers/issues/1889)) ([b062753](https://github.com/feathersjs/feathers/commit/b0627530d61babe15dd84369d3093ccae4b780ca))





## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04)


Expand Down
8 changes: 4 additions & 4 deletions packages/authentication/package.json
@@ -1,7 +1,7 @@
{
"name": "@feathersjs/authentication",
"description": "Add Authentication to your FeathersJS app.",
"version": "4.5.2",
"version": "4.5.3",
"homepage": "https://feathersjs.com",
"main": "lib/",
"types": "lib/",
Expand Down Expand Up @@ -43,9 +43,9 @@
"access": "public"
},
"dependencies": {
"@feathersjs/errors": "^4.5.2",
"@feathersjs/feathers": "^4.5.2",
"@feathersjs/transport-commons": "^4.5.2",
"@feathersjs/errors": "^4.5.3",
"@feathersjs/feathers": "^4.5.3",
"@feathersjs/transport-commons": "^4.5.3",
"@types/jsonwebtoken": "^8.3.9",
"debug": "^4.1.1",
"jsonwebtoken": "^8.5.1",
Expand Down
16 changes: 16 additions & 0 deletions packages/client/CHANGELOG.md
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [4.5.4](https://github.com/feathersjs/feathers/compare/v4.5.3...v4.5.4) (2020-04-29)

**Note:** Version bump only for package @feathersjs/client





## [4.5.3](https://github.com/feathersjs/feathers/compare/v4.5.2...v4.5.3) (2020-04-17)

**Note:** Version bump only for package @feathersjs/client





## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04)

**Note:** Version bump only for package @feathersjs/client
Expand Down

0 comments on commit be85b23

Please sign in to comment.