Reputation: 78941
A logical stuck point. I am building a simple ACL, and I am just confused. I am just trying to do this the right way.
Take a example of a simple model based ACL.
A table of managing users tbl_user
id | userid |
-------------
1 | nabin |
2 | suman |
Another table for managing groups tbl_group
id | groupname |
-----------------
1 | admin |
2 | member |
3 | editor |
4 | moderator |
Another table for maintaining groups and users. tbl_roles
id | userid | groupid
-----------------------
1 | 1 | 1
2 | 1 | 2
3 | 2 | 2
4 | 2 | 3
5 | 2 | 4
Now a table for managing the access tbl_acl
id | groupid | appresourceid
----------------------------
1 | 3 | 1
On this table, I will store the deny list, cause deny list will definitely be shorter than the access list.
Now, according to the example groupid:3 (editor)
, has been denied to the resource 1(suppose this is the administration area).
But, if you take userid: 2(suman)
, then he is a both editor
and moderator
. As per the rule of tbl_acl
, editor
should be denied, where as moderator
should be allowed.
Should he be allowed to access the resource or should be denied? Allowed FIRST or Denied FIRST. Which should be prioritized?
Some ways of looking into this
member
too. So if we are prioritizing the allow over the deny. Member will have access as an moderator. Unless, member are blocked tooP.S. I am well aware of this topic being debatable. So, facts would be appreciated (not saying don't) over opinions and guesses.
Upvotes: 4
Views: 1645
Reputation: 121
I think a mental image of building would be appropriate. 2 Scenario's:
The 'allow by default' scenario:
In case of denying access in this scenario it would look like this:
This goes the same with the closet in each room etc. This is done for every person that wants to enter the room and should be compared to a blacklist to either deny or allow.
How is this practical?
The 'deny by default' scenario:
In case of allowing access in this scenario it would look like this:
Is this practical? It is even possible to give each person a unique key. Yes, that are a lot of keys to manage and administer. But the win? It will provide granularity and thus flexibility while increasing security.
Upvotes: 0
Reputation: 20982
You are encountering this dilemma because you have adopted the rather non-standard approach of allowing access to resources by default. The far more standard approach is to prevent access by default, grant access via one or more "allow" ACL entries, and override any "allow" entries via even a single "deny" entry. Under this approach, any given "deny" entry trumps all "allow" entries. (i.e.: The application should look for denies first and, if it finds any, it doesn't even need to check for allows.)
If you need convincing that the "prevent by default" is a better model than "allow by default", here are a few major differences:
It is generally a better fit for the mental model of permissions management held by most permission administrators, whether they be IT staff or business-role application administrators. (Granted, this is at least partly due to the fact that most other systems they will have administered use this model, but that doesn't make it any less relevant.)
Human error is less likely to result in inappropriate granting of a permission. (i.e.: If the administrator forgets to add an "allow" entry under prevent-by-default, no user ends up being able to access resources that he should not have been able to touch.)
When a new permission is added to the system, nobody without special admin rights can access the target resource(s) until explicit "allow" entries are added.
#3 is particularly compelling. Imagine you deploy a new version of an HR application with a new "view salaries" permission. Would you find it acceptable to allow all users to be granted this permission until someone gets around to adding "deny" entries to your ACLs?
Upvotes: 2
Reputation: 13737
For me 'allow' should win from 'deny' when there are conflicting permissions. Generally you'll have roles spanning a broad feature set but with limited permissions (eg guest) towards roles with greater responsabilities. You will only be able to reuse the general roles when you allow to override the 'denied'.
Example permissions:
1.
deny members all
allow members to view articles
Allow overrules the deny.
Upvotes: 0
Reputation: 4526
in my opinion the default should be to deny access, unless they are allowed to access it as a member of a group (in tbl_acl).
Upvotes: 0