loopback icon indicating copy to clipboard operation
loopback copied to clipboard

ACL for models extending User Model is not working

Open jannyHou opened this issue 10 years ago • 33 comments

  1. slc loopback to create a new lb app
  2. slc loopback:model to create a model extends User model
  3. node . and open explorer
  4. Try endpoint Post/ myusers/ :

Result:

{
  "username": "string",
  "email": "[email protected]",
  "id": 1
}

Try endpoint Get/ myusers/ :
Result:

[
  {
    "username": "string",
    "email": "[email protected]",
    "id": 1
  }
]

By default, people should not be able to Get /myusers without login.

jannyHou avatar Apr 29 '16 15:04 jannyHou

@ebarault Super awesome! What is the temporary solution for this issue?

maziarz avatar Apr 04 '17 15:04 maziarz

there's currently no clean one i'm afraid, the best i see is to create you own User base model, reusing the code from the built-in model and removing the incriminated ACLs from this custom User base model

ebarault avatar Apr 04 '17 15:04 ebarault

@ebarault I do not want to point fingers, but i just came from Django REST framework and getting a bit cold feet, especially since LB encourages extending the base model to create a custom User model, it does not seem to extend the ACL methodology quite well. I am just crossing my fingers that i do not fall over more weird design defects. Sorry if i sound rude, it was not intentional.

maziarz avatar Apr 04 '17 17:04 maziarz

@maziarz: no offense taken. I'm a community maintainer, doing my best to sort some problems out, one at a time. Community is doing a great job here so does the Strongloop team (now joined by IBM). The framework is nearly extensible to the infinite and everyone expects a tone from it OOTB, which is fine :-) but it just take some time and/or your joined efforts to contribute in fixing the issues that matter most to you.

ebarault avatar Apr 04 '17 19:04 ebarault

@ebarault you are doing a good job as far as i can see! I will eat the default ACL's for now until juggler gets released with new shoes :-)

maziarz avatar Apr 04 '17 19:04 maziarz

A new version of Datasource juggler seems to have been published 18 hours ago. But doesn't look like it fixed the issue.

Yup the PR above has not been merged yet.

kodepareek avatar Apr 18 '17 13:04 kodepareek

Fix is merged through this PR https://github.com/strongloop/loopback-datasource-juggler/pull/1289 Closing this issue.

rashmihunt avatar Jun 30 '17 20:06 rashmihunt

So to be clear, the fix is that all ACLS for models extending others should work now? I just want to be clear on what/how it was corrected.

cfjedimaster avatar Jun 30 '17 20:06 cfjedimaster

@bajtos @raymondfeng - since you have reviewed the community PR strongloop/loopback-datasource-juggler#1289, can you please answer @cfjedimaster 's above question?

rashmihunt avatar Jul 10 '17 19:07 rashmihunt

I re-read the discussion in strongloop/loopback-datasource-juggler#1289 to refresh my memory. I believe that when a child model is created, ACLs defined by the parent model are merged with ACLs defined by the child model in such way that child model ACL entries take precedence. So yes, all ACLs for models extending others should work now.

bajtos avatar Jul 11 '17 07:07 bajtos

@bajtos - I'am implementing this case in my project, child model ACL entries have no effects, only parent's ACL are applied. I'm using loopback 3.22.2.

"loopback": "^3.22.2", "loopback-boot": "^2.27.1", "loopback-component-explorer": "^4.3.1", "loopback-component-logger": "^1.0.0", "loopback-connector-mongodb": "^3.6.0",

pbourdu avatar Oct 04 '18 09:10 pbourdu

@pbourdu I see. Please create a small app reproducing the problem (see Reporting bugs), open a new issue and then post a link to that new issue here.

bajtos avatar Oct 09 '18 12:10 bajtos

@bajtos - I'am implementing this case in my project, child model ACL entries have no effects, only parent's ACL are applied. I'm using loopback 3.22.2.

"loopback": "^3.22.2", "loopback-boot": "^2.27.1", "loopback-component-explorer": "^4.3.1", "loopback-component-logger": "^1.0.0", "loopback-connector-mongodb": "^3.6.0",

Same issue: STEPS: Create a new loopback app Create new Model e.g "Appuser" using "User" as base model Set ACLs on "Appuser" to grant everyone access => ACLs for the child model has not effect

eyoma avatar Nov 27 '18 00:11 eyoma