ACL for models extending User Model is not working
slc loopbackto create a new lb appslc loopback:modelto create a model extends User modelnode .and open explorer- 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.
@ebarault Super awesome! What is the temporary solution for this issue?
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 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: 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 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 :-)
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.
Fix is merged through this PR https://github.com/strongloop/loopback-datasource-juggler/pull/1289 Closing this issue.
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.
@bajtos @raymondfeng - since you have reviewed the community PR strongloop/loopback-datasource-juggler#1289, can you please answer @cfjedimaster 's above question?
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 - 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 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 - 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