Skip to content

Policy for RBAC System with domain and resource #441

@brt-srini-rama

Description

@brt-srini-rama

Hi,
I got to the situation were I think it has overwhelms the Casbin's feature. Please suggest if any suitable model that I can leverage from Casbin to match my use case.

use case is :
UC-1 : userA allowed to perform action on resource_A in certain domain during certain time period in daily basis only during weekdays. and none of the action are allowed on weekends(So I need to differentiate between weekdays and weekends).

UC-2 : userB (Admin) allowed to perform perform action on all resources_All in many domains during all times on all days of the week.

right now I manage to get the use case working up until time restrictions, still could not able to impose day restrictions.
To make this working up to timing restrictions I have used almost all the "request" and "policy" rules fields, I mean I used all the 6 columns/fields (sub, dom, res, action1, action2) of the Casbin's
here is my model. Example from my policy file is p, User,domain, resource1, booking, create, 8, 20: and later attached the user say "Shri" to this role using g function as below. g, Shri, User, domain

[request_definition]
r = sub, dom, obj, act1, act2, time

[policy_definition]
; start time and end time should be 0 - 24 Hrs bound value
p = sub, dom, obj, act1, act2, strt_time, end_time

[role_definition]
;User Role mapping with subject
g = _, _, _
;Admin Role mapping with subject
g2 = _, _, _
;Desk Role maping with desk entity
g3 = _, _
;Room Role mapping with room entity
g4 = _, _

[policy_effect]
e = some(where (p.eft == allow))

[matchers]
m = ((g(r.sub, p.sub, r.dom) || g2(r.obj, p.obj, r.dom)) && (g3(r.obj, p.obj) || g4(r.obj, p.obj)) && (r.act2 == p.act2 && r.act1 == p.act1) && ((r.time >= p.strt_time && r.time < p.end_time) || isAdmin(r.sub, r.dom)))

In the above matcher function, isAdmin(r.sub, r.dom) is my custom matcher function registered to identify whether a user is a Admin user or the normal user, it will return true if the user is Admin, so in the matcher condition ((r.time >= p.strt_time && r.time < p.end_time) || isAdmin(r.sub, r.dom)) will exclude the timing restriction for him.

Now to add the day restriction, I am really hanged up, I still tried the following policy definition in .csv file p, Weekdays, Mon, Tue, Wed, Thu, fri but I am confused how to validate this policy rule again the request arguments which does not have a "day" field in my request_definition.

Please suggest any suitable model I should strict to make this scenarios covered.

Thanks in Advance.
Srini.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions