ACL seems to be not working: 401 Authorization Required
Hello, I created a Model named "ShippingAddresses" which has following ACL rules.
[
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "DENY"
},
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$owner",
"permission": "ALLOW"
},
{
"accessType": "EXECUTE",
"principalType": "ROLE",
"principalId": "$authenticated",
"permission": "ALLOW",
"property": "create"
},
{
"accessType": "WRITE",
"principalType": "ROLE",
"principalId": "$owner",
"permission": "ALLOW"
}
]
When I create a record by making a POST call on endpoint /api/shipping_addresses it works perfectly fine but when I make a GET request on same endpoint /api/shipping_addresses it's not working.
Also, just for side note, I have ShippingAddresses model's relation defined with Account (inherits User). Relation is: User -> hasMany ShippingAddress , ShippingAddress -> belongsTo Account.
I read ACL documentation on Loopback Official docs but I'm lost. Everything seems to set correctly but still getting 401: Authorization Required.
Just so you know, I'm using the same access_token to create record (HTTP POST) as well as for getting records (HTTP GET) so that it doesn't see both requests from different users (owners).
See my example at https://github.com/strongloop/loopback-example-access-control and the ACL docs at https://docs.strongloop.com/display/public/LB/Authentication%2C+authorization%2C+and+permissions.
For future reference, please post questions to https://groups.google.com/forum/#!forum/loopbackjs. See https://github.com/strongloop/loopback/wiki/Questions for more details.
That's not helpful. Do you think I didn't go through the links you ping me?
I just asked a very simple question. Can you please see the ACL definition above and tell me why I can create but not update or get?
@achintverma This is not the correct place to ask questions (Google Groups, StackOverflow and Gitter are the official channels we support as stated in the link I provided you). If you believe this is a legitimate bug, then I will reopen the issue after you provide a sample project. I will then try to reproduce the issue on my end to confirm the bug. See https://github.com/strongloop/loopback/wiki/Reporting-issues#bug-report
That's not helpful. Do you think I didn't go through the links you ping me?
I just asked a very simple question. Can you please see the ACL definition above and tell me why I can create but not update or get?
I understand you asked asked a simple question, but please read the first line of reporting issues: DO NOT post questions using GitHub issues.
Have you tried creating a new js file with this:
module.exports = function enableAuthentication(server) {
server.enableAuth();
};