Delete User always return 401 Access Denied, even with correct access token; Broken since v1.8.4
Tried on Loopback v1.8.5 and v1.8.4. Delete User always returns 401 even with correct access token.
curl -X DELETE -H "Authorization: ZSzcKBG3chzhQTTuDsua0h0R4VPg8bFCDqtR5LKvfMr5DgnYbmtAAdXXz3WgrVTP" http://127.0.0.1:3000/api/users/30
{ "error": { "name": "Error", "status": 401, "message": "Access Denied", "statusCode": 401, "stack": "Error: Access Denied\n at /var/app/current/node_modules/loopback/lib/application.js:301:21\n at /var/app/current/node_modules/loopback/lib/models/acl.js:466:17\n ... ... ...
Rolled back to Loopback v1.8.3, then it worked.
DELETE /api/users/30 204 108ms
I can reproduce the problem. This seems to be a side effect caused by https://github.com/strongloop/strong-remoting/commit/96335deeaa2b2cddbe25ee1ffae326be4dd906de. The deleteById/destroyById/removeId are aliases for the same method. The ACL specifies 'removeById' while now strong-remoting maps the DELETE request to 'destroyById'.
There are two ways to fix it:
- Add an ACL rule to User model so that 'destroyById' is allowed by '$owner'
- Have the ACL check honor the aliases
@ritch I believe that you are working on 2. Can you confirm?
Downgrading loopbacks dependency to strong-remoting to 1.3.x should fix this in the short term. The issue is related to remote method aliasing not being supported correctly by ACL.
That should be released shortly but some major parts of ACL have to be re-written so it's not a minor fix.
On Jun 1, 2014, at 10:06 PM, Raymond Feng [email protected] wrote:
I can reproduce the problem. This seems to be a side effect caused by strongloop/strong-remoting@96335de. The deleteById/destroyById/removeId are aliases for the same method. The ACL specifies 'removeById' while now strong-remoting maps the DELETE request to 'destroyById'.
There are two ways to fix it:
Add an ACL rule to User model so that 'destroyById' is allowed by '$owner' Have the ACL check honor the aliases @ritch I believe that you are working on 2. Can you confirm?
— Reply to this email directly or view it on GitHub.
I have a quick tactical fix by adding an extra ACL rule to cover 'destroyById'. Should we go with the route before you have the final fix?
The fix is ready at https://github.com/strongloop/loopback/pull/298
Fix released as v1.8.6.