You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unauthorized access permitted when using multiple user models #3506
A test for the scenario can be run with npm test, and not so surprisingly found at test/test.js.
Steps to reproduce
Setup Customer and Admin models based on User
Setup a CustomAccessToken model based on AccessToken
Setup a polymorphic hasMany "accessTokens" relation from Customer and Admin to CustomAccessToken with "userId" as the foreign key and "principalType" as the discriminator
Setup a polymorphic belongsTo "user" relation from CustomAccessToken with "userId" as the foreign key and "principalType" as the discriminator
Create a Customer account
Create an Admin account
Login as Customer
GET /admins/{customer_id}?access_token={customer_access_token} returns the admin who happens to have the same numeric id
Expected result
The server should respond with a 401.
Actual result
The server responds with a 200. The admin’s information is returned in the response body.
Are you using MySQL or any db not using a random guid as key?
If yes then it's a known issue of the dual user set-up.
In order to mitigate it you can generate your own unique ids in the meantime
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.
@bencallaway are you aware that your sandbox is for LB2? I've just upgraded all the dependencies to the latest LB3 versions, and the unit test now passes! This is probably due to #3140 recently landing?
I think we can savely close this now. Below the important bits of package.json that I used to make the test pass:
Activity
ebarault commentedon Jul 19, 2017
Are you using MySQL or any db not using a random guid as key?
If yes then it's a known issue of the dual user set-up.
In order to mitigate it you can generate your own unique ids in the meantime
bencallaway commentedon Jul 19, 2017
@ebarault Yes, I'm using PostgreSQL with integer ids. Do you know of any URLs pertaining to this as a known issue?
stale commentedon Sep 17, 2017
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
stale commentedon Oct 1, 2017
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the
CODEOWNERSfile at the top-level of this repository.lehni commentedon Oct 5, 2017
@ebarault mentioned that #3140 is related to this, which was just merged.
But there are untackled problems still, mainly this: e17132d#r104612589
I am reopening as this still needs resolving.
lehni commentedon Oct 5, 2017
@bencallaway are you aware that your sandbox is for LB2? I've just upgraded all the dependencies to the latest LB3 versions, and the unit test now passes! This is probably due to #3140 recently landing?
I think we can savely close this now. Below the important bits of
package.jsonthat I used to make the test pass:{ "name": "loopback-sandbox", "main": "server/server.js", "scripts": { "lint": "eslint .", "start": "node .", "test": "mocha test", "posttest": "npm run lint && nsp check" }, "dependencies": { "compression": "^1.7.0", "cors": "^2.8.4", "helmet": "^3.8.0", "loopback": "^3.14.0", "loopback-boot": "^2.26.1", "loopback-component-explorer": "^5.0.0", "serve-favicon": "^2.0.1", "strong-error-handler": "^2.2.0" }, "devDependencies": { "eslint": "^4.8.0", "eslint-config-loopback": "^8.0.0", "mocha": "^4.0.0", "nsp": "^2.8.0", "supertest": "^3.0.0" }