[Question] Hierarchical domains with (hierarchical) roles
- Dominant language
- Go
- Stars
- 20.4k
- Forks
- 1.8k
- Avg merge
- 5d 11h
- Merged PRs (30d)
- 2
Description
**What's your scenario? What do you want to achieve?**
Pretty much a follow-up from https://github.com/casbin/casbin/issues/718#issuecomment-889785940
> So, do you think this problem is solvable by Casbin? I think this is pretty typical use case of hierarchical RBAC where you do not want to define global role hierarchy into each domain.
>
> General idea would be pretty similar to the original question:
>
> - global domain
> - - subdomain1
> - - - lowersubdomain1
> - - subdomain2
>
> 1. So if `alice` is an `admin` in `global domain`, she should be an `admin` in all domains below it (`subdomain1`, `lowersubdomain1`, `subdomain2`).
> 1. This should happen without any additional policy lines. `g, alice, admin, global domain` should be sufficient
> 2. Defining what permissions `admin` has in each domain is still required.
> 2. If `bob` is an `admin` in `subdomain1`, he should have `admin` access to `lowersubdomain1`
> 1. But no access to any other domain
**Your model:**
```ini
[request_definition]
r = sub, dom, obj, act
[policy_definition]
p = sub, dom, obj, act
[role_definition]
g = _, _, _
g2 = _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = g(r.sub, p.sub, r.dom) && g2(r.dom, p.dom) && regexMatch(r.obj, p.obj) && regexMatch(r.act, p.act)
```
**Your policy:**
```
p, admin, global_domain, data1, (read|write)
p, admin, sub_domain, data2, (read|write)
g, alice, admin, global_domain
g, bob, admin, sub_domain
g2, sub_domain, global_domain
```
**Your request(s):**
```
alice, global_domain, data1, read --> true, correct
alice, sub_domain, data2, read --> false, incorrect
bob, sub_domain, data2, read --> true, correct
```
Contributor guide
Assessment
This issue has not been assessed yet.