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
ACL for models extending User Model is not working #2270
I think there is one catch: ACL is represented as a list of access-control entries and AFAIK we don't have a declarative way for clearing this list from model JSON file. This means that when a child model inherits ACL from the parent, it is not possible to drop parent's ACL and build a new ACL from scratch.
We should find a solution for that while working on the fix for this issue.
Since this was discovered when extending a built-in model, I think it relates to #397 A better way for customizing built-in models and models from components
@bajtos Are you saying this is a bug everywhere, or that it wasn't intended to work in the first place?
To your second point - what if the logic was this: Given Child extends Parent - if my child.json file has no acls property, then it inherits. If it has "acls":[], that means "I'm not inheriting Parent, I'm setting acls to an empty array."
Are you saying this is a bug everywhere, or that it wasn't intended to work in the first place?
I believe that we have never implemented inheritance of ACL. I don't think it was an intentional decision, just the result of the way how we implemented the feature.
To your second point - what if the logic was this: Given Child extends Parent - if my child.json file has no acls property, then it inherits. If it has "acls":[], that means "I'm not inheriting Parent, I'm setting acls to an empty array."
I think the typical scenario would be to built a custom ACL in the JSON file, which would not be supported if you had to specify "acls":[].
Here are few other ideas of what can be done:
When "acls" is not defined, or set to a special value like "inherit" (notice it's a string, not an array as usually), the model will inherit "acls" from the parent. If "acls" is set, parent ACL will be discarded and the ACL provided in the child model will be used instead.
Also if we add a setting inheritAcls, then we can implement it in 2.x and modify model generator to set the flag to true. That way we get backwards compatibility for existing codebase and still have the benefit of doing things the right way for newly created models.
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.
I re-read the discussion in loopbackio/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.
@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.
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
Activity
bajtos commentedon May 2, 2016
I think ACLs are not inherited when extending a model. See #157 for more details.
bajtos commentedon May 2, 2016
I think there is one catch: ACL is represented as a list of access-control entries and AFAIK we don't have a declarative way for clearing this list from model JSON file. This means that when a child model inherits ACL from the parent, it is not possible to drop parent's ACL and build a new ACL from scratch.
We should find a solution for that while working on the fix for this issue.
Since this was discovered when extending a built-in model, I think it relates to #397 A better way for customizing built-in models and models from components
cfjedimaster commentedon May 2, 2016
@bajtos Are you saying this is a bug everywhere, or that it wasn't intended to work in the first place?
To your second point - what if the logic was this: Given Child extends Parent - if my child.json file has no acls property, then it inherits. If it has "acls":[], that means "I'm not inheriting Parent, I'm setting acls to an empty array."
That may not be backwards compat though.
sahilanguralla commentedon May 3, 2016
I am in middle of something and I need it. please fix it ASAP. Also please suggest any workaround for the time being, if possible. Thanks in advance.
bajtos commentedon May 3, 2016
I believe that we have never implemented inheritance of ACL. I don't think it was an intentional decision, just the result of the way how we implemented the feature.
I think the typical scenario would be to built a custom ACL in the JSON file, which would not be supported if you had to specify
"acls":[].Here are few other ideas of what can be done:
The last option looks best to me.
@raymondfeng @ritch @superkhau thoughts?
bajtos commentedon May 3, 2016
Also if we add a setting
inheritAcls, then we can implement it in 2.x and modify model generator to set the flag to true. That way we get backwards compatibility for existing codebase and still have the benefit of doing things the right way for newly created models.27 remaining items
ebarault commentedon Apr 4, 2017
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
maziarz commentedon Apr 4, 2017
@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.
ebarault commentedon Apr 4, 2017
@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.
maziarz commentedon Apr 4, 2017
@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 :-)
kodepareek commentedon Apr 18, 2017
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.
rashmihunt commentedon Jun 30, 2017
Fix is merged through this PR loopbackio/loopback-datasource-juggler#1289 Closing this issue.
cfjedimaster commentedon Jun 30, 2017
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.
rashmihunt commentedon Jul 10, 2017
@bajtos @raymondfeng - since you have reviewed the community PR loopbackio/loopback-datasource-juggler#1289, can you please answer @cfjedimaster 's above question?
bajtos commentedon Jul 11, 2017
I re-read the discussion in loopbackio/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.
pbourdu commentedon Oct 4, 2018
@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",bajtos commentedon Oct 9, 2018
@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.
eyoma commentedon Nov 27, 2018
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