Commit Graph

2145 Commits

Author SHA1 Message Date
Loay 131b78dc84 Merge pull request #3511 from strongloop/empty-password-lb3
Add unit test for empty password
2017-07-25 15:42:22 -04:00
loay a3bf813088 Update Travis registry 2017-07-25 14:40:05 -04:00
loay c761dc5279 Add unit test for empty password 2017-07-25 14:40:04 -04:00
Diana Lau d1f6129eaf Merge pull request #3513 from strongloop/add-codeowner
Add CODEOWNER file
2017-07-25 14:37:20 -04:00
Diana Lau 5ed74ab24b Add CODEOWNER file 2017-07-25 09:41:09 -04:00
Miroslav Bajtoš 839c58639d
3.9.0
* Remove observers from Model on end of the stream (Alexei Smirnov)
 * Fix Model#settings.acls doc type signature (Farid Nouri Neshat)
 * Use `localhost` instead of `::` for local (Daijiro Wachi)
 * Fix API doc for Model class property type (Candy)
 * Update package.json (sqlwwx)
 * Support remoting adapters with no ctx.req object (Piero Maltese)
 * update strong-error-handler (sqlwwx)
2017-07-12 16:17:00 +02:00
Miroslav Bajtoš f7b88e3435 Merge pull request #3474 from bigcup/fixChangeStreamIssue#1569
Removed observers from a Model after finish of the stream
2017-07-12 16:15:20 +02:00
Alexei Smirnov 8ed92a12e0
Remove observers from Model on end of the stream
- Remove flags and properly finish the stream.
 - Destroy emits an end event for compability with ending of
   ReadableStream now.
 - Check for default implementation of destroy() method,
   because in Node.js 8 all types of streams have a native one.
2017-07-12 10:28:27 +02:00
Miroslav Bajtoš ca3a21ddd5 Merge pull request #3444 from alFReD-NSH/patch-2
Fix Model#settings.acls doc type signature
2017-06-23 16:43:47 +02:00
Farid Nouri Neshat 065eedab7b
Fix Model#settings.acls doc type signature 2017-06-23 16:25:54 +02:00
Miroslav Bajtoš f85551b715 Merge pull request #3450 from watilde/fixes-3179
Use `localhost` instead of `::` for local
2017-06-21 17:51:24 +02:00
Daijiro Wachi 75b4a45968 Use `localhost` instead of `::` for local 2017-06-15 22:29:37 +02:00
Candy 1be0a9f3d5 Merge pull request #3448 from strongloop/fix_type
Fix API doc for Model class property type
2017-06-14 15:49:22 -04:00
Candy 04983831ca Fix API doc for Model class property type 2017-06-14 14:38:55 -04:00
Miroslav Bajtoš 359a6a5762 Merge pull request #3396 from sqlwwx/master
Update strong-error-handler to 2.x
2017-05-23 16:58:59 +02:00
sqlwwx 3a10209502 Update package.json 2017-05-23 09:14:38 +08:00
sqlwwx 375d476d28 Update package.json 2017-05-23 09:13:27 +08:00
Miroslav Bajtoš f8db64c9c3 Merge pull request #3376 from pierissimo/patch-1
Support remoting adapters with no ctx.req object
2017-05-22 15:23:51 +02:00
Piero Maltese 4735efa41f
Support remoting adapters with no ctx.req object
Fix `Model.createOptionsFromRemotingContext()` to correctly handle
the case where `ctx.req` is not defined, e.g. when using
websocket-based adapters.
2017-05-22 13:21:44 +02:00
sqlwwx ee68b8067c update strong-error-handler 2017-05-13 18:21:15 +08:00
Raymond Feng 9fb67315f9 3.8.0
* Refactor access token to make it extensible (Raymond Feng)
2017-05-02 11:16:34 -07:00
Raymond Feng a9c13a8f6c Merge pull request #3381 from strongloop/feature/refactor-access-token-id
Refactor access token to make it extensible
2017-05-02 13:14:31 -05:00
Raymond Feng 69df11bb8e Refactor access token to make it extensible
1. Make it possible to reuse getIdForRequest()
2. Introduce a flag to control if oAuth2 bearer token should be base64
encoded
3. Promote resolve() to locate/validate access tokens by id
2017-05-02 10:55:51 -07:00
Miroslav Bajtoš 6a4bd6d09f
3.7.0
* Remote method /user/:id/verify (ebarault)
 * Implement more secure password flow (Miroslav Bajtoš)
 * Add User.setPassword(id, new, cb) (Miroslav Bajtoš)
 * Fix method setup in authorization-scopes.test (Miroslav Bajtoš)
 * Add missing tests for reset password flow (Miroslav Bajtoš)
 * forwarding context options in user.verify (ebarault)
 * update deprecated dependencies (Diana Lau)
 * Add support for scoped access tokens (Miroslav Bajtoš)
 * Fix user-literal rewrite for anonymous requests (Aaron Buchanan)
2017-04-27 13:19:17 +02:00
Eric Barault d1719fd9a8 Merge pull request #3314 from strongloop/feature/enable-email-verification-replay
Provide a solution to finish the user's registration when the user identity verification message is lost or has expired
2017-04-26 20:01:38 +02:00
ebarault b9fbf51b27 Remote method /user/:id/verify
This commit adds:
- user.prototype.verify(verifyOptions, options, cb)
- remote method /user/:id/verify
- User.getVerifyOptions()

The remote method can be used to replay the sending of a user
identity/email verification message.

`getVerifyOptions()` can be fully customized programmatically
or partially customized using user model's `.settings.verifyOptions`

`getVerifyOptions()` is called under the hood when calling the
/user/:id/verify remote method

`getVerifyOptions()` can also be used to ease the building
of identity verifyOptions:

```js
var verifyOptions = {
  type: 'email',
  from: 'noreply@example.com'
  template: 'verify.ejs',
  redirect: '/',
  generateVerificationToken: function (user, options, cb) {
    cb('random-token');
  }
};

user.verify(verifyOptions);
```

NOTE: the `User.login()` has been modified to return the userId when
failing due to unverified identity/email. This userId can then be used
to call the /user/:id/verify remote method.
2017-04-26 19:05:41 +02:00
Miroslav Bajtoš b96605c63a Merge pull request #3350 from strongloop/feature/set-password-with-token
Set password with token, disable password changes via patch/replace
2017-04-20 10:47:04 +02:00
Miroslav Bajtoš c5ca2e1c2e
Implement more secure password flow
Improve the flow for setting/changing/resetting User password to make
it more secure.

 1. Modify `User.resetPassword` to create a token scoped to allow
    invocation of a single remote method: `User.setPassword`.

 2. Scope the method `User.setPassword` so that regular tokens created
    by `User.login` are not allowed to execute it.

For backwards compatibility, this new mode (flow) is enabled only
when User model setting `restrictResetPasswordTokenScope` is set to
`true`.

 3. Changing the password via `User.prototype.patchAttributes`
    (and similar DAO methods) is no longer allowed. Applications
    must call `User.changePassword` and ask the user to provide
    the current (old) password.

For backwards compatibility, this new mode (flow) is enabled only
when User model setting `rejectPasswordChangesViaPatchOrReplace` is set
to `true`.
2017-04-20 10:22:21 +02:00
Miroslav Bajtoš e27419086c
Add User.setPassword(id, new, cb)
Implement a new method for changing user password with password-reset
token but without the old password.

REST API

    POST /api/users/reset-password
    Authorization: your-password-reset-token-id
    Content-Type: application/json

    {"newPassword": "new-pass"}

JavaScript API

    User.setPassword(userId, newPassword[, cb])
    userInstance.setPassword(newPassword[, cb])

Note: the new REST endpoint is not protected by scopes yet, therefore
any valid access token can invoke it (similarly to how any valid access
token can change the password via PATCH /api/users/:id).
2017-04-20 10:18:49 +02:00
Miroslav Bajtoš d95ec66a23
Fix method setup in authorization-scopes.test
Fix the code builing a scoped method to correctly handle the case
when the setup method is called twice and the previously defined
method has to be overriden with new remoting metadata.
2017-04-18 13:01:15 +02:00
Miroslav Bajtoš 9c63abef52
Add missing tests for reset password flow 2017-04-18 13:01:14 +02:00
Miroslav Bajtoš faa4975b78 Merge pull request #3344 from strongloop/maintenance/passing-context-options-in-user.verify
forward context options in user.verify
2017-04-12 09:13:20 +02:00
ebarault 912aad8b35 forwarding context options in user.verify
change original "options" argument to "verifyOptions"
adds ctx options argument as "options"
forward context "options" down to relevant downstream functions
review verifyOptions assertions
code cleaning
tests code cleaning
2017-04-11 17:54:45 +02:00
Diana Lau 31e22d3b3f Merge pull request #3345 from strongloop/3.x/update-dependencies
update deprecated dependencies
2017-04-10 15:10:26 +00:00
Diana Lau 52d3faed80 update deprecated dependencies 2017-04-07 15:09:31 -04:00
Miroslav Bajtoš 95240598b3 Merge pull request #3313 from strongloop/feature/access-token-scopes
Add support for scoped access tokens
2017-04-07 13:28:32 +02:00
Miroslav Bajtoš c5145bdf34
Add support for scoped access tokens
Define a new property `AccessToken.scopes` to contain the list of
scopes granted to this access token.

Define a new remote method metadata `accessScopes` to contain a list
of scope name required by this method.

Define a special built-in scope name "DEFAULT" that's used when
a method/token does not provide any scopes. This allows access
tokens to grant access to both the default scope and any additional
custom scopes at the same time.

Modify the authorization algorithm to ensure that at least one
of the scopes required by a remote method is allowed by the scopes
granted to the requesting access token.

The "DEFAULT" scope preserve backwards compatibility because existing
remote methods with no `accessScopes` can be accessed by (existing)
access tokens with no `scopes` defined.

Impact on existing applications:

 - Database schema must be updated after upgrading the loopback version

 - If the application was already using a custom `AccessToken.scopes`
   property with a type different from an array, then the relevant code
   must be updated to work with the new type "array of strings".
2017-04-07 13:04:40 +02:00
Miroslav Bajtoš 9fef5284c7 Merge pull request #3292 from aaronbuchanan/fix/unauthorized-current-user-literal
Fix user-literal rewrite for anonymous requests
2017-04-04 18:52:08 +02:00
Aaron Buchanan fbf818b2dc
Fix user-literal rewrite for anonymous requests
Currently any `currentUserLiteral` routes when accessed with a bad
token throw a 500 due to a SQL error that is raised because
`Model.findById` is invoked with `id={currentUserLiteral}`
(`id=me` in our case) when the url rewrite fails.

This commit changes the token middleware to return 401 Not Authorized
when the client is requesting a currentUserLiteral route without
a valid access token.
2017-04-04 16:30:08 +02:00
Miroslav Bajtoš 0499d09d6b
3.6.0
* Add new event "remoteMethodAdded" (Flavien DAVID)
 * Forward options in prepareForTokenInvalidation (Miroslav Bajtoš)
 * Check max password length in User.changePassword (Miroslav Bajtoš)
 * Add User.changePassword(id, old, new, cb) (Miroslav Bajtoš)
 * Propagate authorized roles in remoting context (ebarault)
 * Run the latest Node.js 7 version on Travis again (Miroslav Bajtoš)
 * Lock down Travis CI Node 7 version to 7.7.1 (Miroslav Bajtoš)
 * README: add a link to our announcements list (Miroslav Bajtoš)
 * Allow custom properties of Change Model (agriwebb build)
 * Fix User.verify to convert uid to string (phairow)
 * Pass options.verificationToken to templateFn (Hiran del Castillo)
 * fix custom token model in token middleware (ebarault)
 * Update runtime dependencies (Miroslav Bajtoš)
 * Verify User and AccessToken relations at startup (Miroslav Bajtoš)
 * Deep-clone model settings in lib/builtin-models (Miroslav Bajtoš)
 * Use local registry in test/replication.rest.test (Miroslav Bajtoš)
 * Fix test/access-token.test to use local registry (Miroslav Bajtoš)
 * Fix context passing in OWNER role resolver (Benjamin Schuster-Boeckler)
2017-03-31 16:09:09 +02:00
Miroslav Bajtoš 75fdd3cf32 Merge pull request #3322 from DAVIDFlavien/fix/nestRemotingRoutes
Add new event "remoteMethodAdded"
2017-03-31 16:02:32 +02:00
Flavien DAVID 981bd309fc
Add new event "remoteMethodAdded"
Emit a new method "remoteMethodAdded" whenever a new method is added,
typically when `Model.remoteMethod` or `Model.nestRemoting` is called.

The method is emitted both by the Model affected and the application
object.
2017-03-31 15:32:19 +02:00
Miroslav Bajtoš 53182affef Merge pull request #3316 from strongloop/fix/options-in-token-invalidations-master
Forward options in prepareForTokenInvalidation
2017-03-28 16:17:39 +02:00
Miroslav Bajtoš 94f267884f
Forward options in prepareForTokenInvalidation 2017-03-28 15:59:20 +02:00
Miroslav Bajtoš f736da64f4 Merge pull request #3312 from strongloop/fix/change-password-validation
Check max password length in User.changePassword
2017-03-28 15:59:07 +02:00
Miroslav Bajtoš b550cdcf43
Check max password length in User.changePassword 2017-03-28 15:46:01 +02:00
Miroslav Bajtoš 048110ee01 Merge pull request #3299 from strongloop/feature/change-password-api
Add User.changePassword(id, old, new, cb)
2017-03-24 12:05:41 +01:00
Miroslav Bajtoš 27ed712528
Add User.changePassword(id, old, new, cb)
Implement a new method for changing user passwords the secure way.
The method requires the old password to be provided before a new
password can be used.

REST API:

    POST /api/users/change-password
    Authorization: your-token-id
    Content-Type: application/json

    {"oldPassword":"old-pass", "newPassword": "new-pass"}

JavaScript API:

    User.changePassword(userId, oldPassword, newPassword[, cb])

There is also an instance-level (prototype) method that can be used
from JavaScript:

    userInstance.changePassword(oldPassword, newPassword[, cb])
2017-03-24 11:01:04 +01:00
Miroslav Bajtoš cb7e2114ec Merge pull request #2957 from ebarault/propagate-resolved-roles-in-context
propagate resolved roles in remoting context
2017-03-20 13:34:12 +01:00
ebarault 8aa98a80ef Propagate authorized roles in remoting context
Adds an authorizedRoles object to remotingContext.args.options
which contains all the roles (static and dynamic) that are
granted to the user when performing a request through
strong-remoting to an app with authentication enabled.

The authorizedRoles object for example looks like:
{
  $everyone: true,
  $authenticated: true,
  myRole: true
}

NOTE: this pr also covers a number of jsdoc fixes as well
as refactoring in ACL.js and access-context.js
2017-03-20 12:29:33 +01:00