Repository navigation
Modify loopback.rest to include loopback.token - #263
Conversation
|
Test Failed. To trigger a build add comment - ".test\W+please" |
|
come on, @slnode! test please |
|
Test Failed. To trigger a build add comment - ".test\W+please" |
|
Test Failed. To trigger a build add comment - ".test\W+please" |
|
Ignore ci.strongloop.com, here is the Travis build that passed: https://travis-ci.org/strongloop/loopback/builds/25337075 |
|
LGTM. I think we should accept options for loopback.rest() too. |
There was a problem hiding this comment.
Accept AccessToken as an option to the middleware and default to getModelByType().
IMO Implementing app.getModelByType() should be trivial.
|
I'd rather avoid passing the access-token model to How about adding an option to app.enableAuth({ accessTokenModel: AccessToken });
// stores the model somewhere, e.g. app._authAccessTokenModel
// app.token() or app.rest() can use app._authAccessToken as the defaultOr I can implement |
|
Here is my proposal: merge the patch as it is. Introduce access token option when there is a user asking for it. How about that, @ritch @raymondfeng? |
|
Test Failed. To trigger a build add comment - ".test\W+please" |
Make `loopback.rest` self-contained, so that authentication works
out of the box.
var app = loopback();
app.enableAuth();
app.use(loopback.rest());
Note that cookie parsing middleware is not added, users have to
explicitly configure that if they want to store access tokens
in cookies.
Modify `loopback.token` to skip token lookup when the request already
contains `accessToken` property. This is in line with other
connect-based middleware like `cookieParser` or `json`.
|
Rebased on top of current master, added one more unit test. @ritch @raymondfeng may I merge it? |
|
Test Failed. To trigger a build add comment - ".test\W+please" |
|
LGTM |
…-middleware-alt Modify `loopback.rest` to include `loopback.token`
Make
loopback.restself-contained, so that authentication works out of the box.Note that cookie parsing middleware is not added, users have to explicitly configure that if they want to store access tokens in cookies.
Modify
loopback.tokento skip token lookup when the request already containsaccessTokenproperty. This is in line with other connect-based middleware likecookieParserorjsonand allows developers to install their custom instance ofloopback.tokenmiddleware beforeloopback.rest:This patch is based on the older pull request #167. The major difference is how the AccessToken model is resolved - #167 used a new method
app.getModelByType, this patch uses existingloopback.getModelByType./to @raymondfeng @ritch please review