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
Error "401 Authorization required" when querying methods involving relations #426
I have a model called issues. After logging in through the POST method /Users/login:
I don't have any problems when calling the GET method /issues. I get a list of issues as expected;
When I query a method involving a relation between two models (e.g. GET /issues/{id}/categories), I get the error 401 Authorization required. The same model used to work in Loopback 1.0.
I have the same issue. I also think the 401 Unauthorized is a wrong response. I am authenticated, so it should be 403 forbidden. I'm opening a new issue for that.
This issue (#426) itself is not yet resolved. Defining an ACL on a relation property does not seem to work for me.
Replicate by defining a model, adding a relationship to it (for example many user to many group). Then DENY ALL on * for ROLE $everyone, and finally ALLOW READ/EXECUTE on for ROLE $authenticated. I consequently get access denied for these relationships.
You can put the following into a file at /server/boot/debug.js:
module.exports = function(app) {
var TestUser = app.loopback.getModel('TestUser');
console.log(TestUser.settings.acls);
};
—
Reply to this email directly or view it on GitHub.
The design seems undesirable, but as long as the design is documented (and it looks like it is from @crandmck post), I don't see a problem closing it. I worked around it in my project -- no longer an immediate concern.
@emazzu@crandmck , i think this problem has come again in the latest repo. @raymondfeng , please look into it. This exposes the security loophole for the app in production.
Refer this thread #3518
@emazzu , @crandmck@raymondfeng , this problem is only with custom access token. I reverted to loopback AccessToken model than it started working as intended.
Activity
daankets commentedon Aug 12, 2014
I have the same issue. I also think the 401 Unauthorized is a wrong response. I am authenticated, so it should be 403 forbidden. I'm opening a new issue for that.
gcirne commentedon Aug 12, 2014
I think this has already been implemented: #301
daankets commentedon Aug 12, 2014
This issue (#426) itself is not yet resolved. Defining an ACL on a relation property does not seem to work for me.
Replicate by defining a model, adding a relationship to it (for example many user to many group). Then DENY ALL on * for ROLE $everyone, and finally ALLOW READ/EXECUTE on for ROLE $authenticated. I consequently get access denied for these relationships.
dagumak commentedon Aug 19, 2014
I am having the exact same issue! I spent a few hours digging through anything I can find, but I still couldnt get it to work!
fabien commentedon Aug 19, 2014
@dagumak - can you post the ACL's you defined?
dagumak commentedon Aug 19, 2014
@fabien I posted it here (#459 (comment)), but here it is:
fabien commentedon Aug 19, 2014
I think the core User ACL's are interfering with the ACL's you defined. I recall the following from one of my projects, which overrides all the ACL's:
fabien commentedon Aug 19, 2014
@dagumak the very least you could do is trace your current TestUser.settings.acls to compare them.
dagumak commentedon Aug 19, 2014
@fabien I feel silly for asking, but other than console log, how can I do that?
On Tue, Aug 19, 2014 at 11:32 PM, Fabien Franzen notifications@github.com
wrote:
fabien commentedon Aug 19, 2014
@dagumak console.log is fine
dagumak commentedon Aug 19, 2014
@fabien I am not very familiar with the framework yet, but where are the models loaded and a good place for me to console.log it?
fabien commentedon Aug 19, 2014
You can put the following into a file at /server/boot/debug.js:
raymondfeng commentedon Aug 19, 2014
You can run the application with DEBUG enabled:
$ DEBUG=loopback:security:* node .
Thanks,
Raymond Feng
Co-Founder and Architect @ StrongLoop, Inc.
StrongLoop makes it easy to develop APIs in Node, plus get DevOps capabilities like monitoring, debugging and clustering.
On Aug 19, 2014, at 8:29 AM, Fabien Franzen notifications@github.com wrote:
dagumak commentedon Aug 19, 2014
@fabien Thanks a bunch! Here it is:
SwadhyayStudios commentedon Jan 31, 2015
Is this resolved ? I am still having the same issue
The last thread doesn't help
14 remaining items
mike-aungsan commentedon Oct 28, 2015
@crandmck Many Thanks
superkhau commentedon Feb 4, 2016
Are you guys still running into issues? Can I close this?
jdhiro commentedon Feb 4, 2016
The design seems undesirable, but as long as the design is documented (and it looks like it is from @crandmck post), I don't see a problem closing it. I worked around it in my project -- no longer an immediate concern.
superkhau commentedon Feb 4, 2016
@jdhiro Sounds good. Please open a new issue if you guys are still running into issues. Better yet, submit a patch and we can go from there.
gekko68 commentedon Feb 4, 2016
Yes - i do
sorry for this question but how do I enable the debug view ?
"You can run the application with DEBUG enabled:
$ DEBUG=loopback:security:* node . "
Thanks,
superkhau commentedon Feb 4, 2016
What do you mean debug view? Run
DEBUG=loopback:security:* node .when starting your loopback app.gekko68 commentedon Feb 5, 2016
Hi,
got it working. Thx. U just run the application DEBUG=loopback:security:* node . on commandline .
emazzu commentedon Oct 26, 2017
somebody can help me ? with the same themes ?
emazzu commentedon Oct 26, 2017
if somebody can help me, I send the problem !!!
crandmck commentedon Oct 26, 2017
https://loopback.io/doc/en/contrib/Reporting-issues.html#dont-use-an-issue-to-ask-a-question
emazzu commentedon Oct 26, 2017
Execuse me, but on gitter nobody responds, and I cant resolve the problem, I dont know what I can do !!!
princecharmx commentedon Nov 3, 2017
@emazzu @crandmck , i think this problem has come again in the latest repo. @raymondfeng , please look into it. This exposes the security loophole for the app in production.
Refer this thread #3518
princecharmx commentedon Nov 23, 2017
@emazzu , @crandmck @raymondfeng , this problem is only with custom access token. I reverted to loopback AccessToken model than it started working as intended.