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".
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.
* 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)
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.
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])
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
Allow custom properties to be added to Change Model,
and make change filter customizable through mixins
to allow to add the custom property to the filter
used to look up relevant changes during change replication.
Applications using MongoDB connectors typically have `user.id`
property of type ObjectID.
This commit fixes the code building the verification URL to
correctly convert the user id value into string.
Enhance User.prototype.verify to pass the generated token
to the templating function in addition to other existing properties.
This allows application to build multiple URLs in the email template,
for example in order to provide a different URL for desktop and
mobile browsers.
Fixing server/middleware/token.js to handle correctly the
setup of a custom AccessToken model by name in either
middleware.json or using any of :
app.use(loopback.token({...}));
app.middlewareFromConfig(loopback.token, {...})
app.middleware('auth', loopback.token({...})
Modify `app.enableAuth()` to verify that (custom) User and AccessToken
models have correctly configured their hasMany/belongsTo relations
and print a warning otherwise.
Fix the code loading builtin models to always clone the JSON object
used as model settings/definition. This is needed to allow applications
to modify model settings while not affecting settings of new models
created in the local registry of another app.
Fix the code invalidating access tokens on user email/password changes
to correctly handle the case when the relation
"AccessToken belongs to (subclassed) user" is not configured.
Add a new model-level setting "replicationChunkSize" which allows
users to configure change replication algorithm to issue several
smaller requests to fetch changes and upload updates.
* Fix Role.isOwner() for multiple user models (ebarault)
* Update ISSUE_TEMPLATE.md (Simon Ho)
* Upgrade supertest to 3.x (Miroslav Bajtoš)
* Fix creation of verification links (Miroslav Bajtoš)
* Enable multiple user models (Eric)
* Babelify juggler for Karma tests (Miroslav Bajtoš)
* Fix Karma config to babelify node_modules too (Miroslav Bajtoš)
* Add promise support to built-in model RoleMapping (ebarault)
* Add promise support to built-in model ACL (ebarault)
* Add nyc coverage, report data to coveralls.io (Miroslav Bajtoš)
* Upgrade eslint config, fix linter errors (Miroslav Bajtoš)
* Add missing type to Role properties definition (David Hernandez)
* Preserve sessions on User.save() making no changes (Miroslav Bajtoš)
* Fix logout to handle no or missing accessToken (Ritchie Martori)
* Promise-ify built-in Role model (Miroslav Bajtoš)
* Remove .jscsrc that's no longer used (Miroslav Bajtoš)
* Enable ES6/ES2015 goodness (Miroslav Bajtoš)
* Remove test/support.js from karma config (Miroslav Bajtoš)
* Use English when running Mocha tests (Miroslav Bajtoš)
* Update ISSUE_TEMPLATE (Simon Ho)
* Updating README - add cli and remove arc (Joe Sepi)
* Fix User methods to use correct Primary Key (Aris Kemper)
* Fix User.resetPassword to call createAccessToken() (João Ribeiro)
* Role model: resolves related models by name (Benjamin Kroeger)