casbin_example icon indicating copy to clipboard operation
casbin_example copied to clipboard

How dose g(r.sub, p.sub) work?

Open txjjjjj opened this issue 5 years ago • 4 comments

m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act 
# defines the workflow of authorization:
1. check user's role 
2. check the resource which user is trying to access
3. check the action of user.

can u explain how dose this 1. check user's role work ? why should we pass r.sub and p.sub info g() when we check if a user belongs to a group? if a user do not belong to a group just return faild?

txjjjjj avatar Jan 21 '20 13:01 txjjjjj

m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act 
# defines the workflow of authorization:
1. check user's role 
2. check the resource which user is trying to access
3. check the action of user.

can u explain how dose this 1. check user's role work ? why should we pass r.sub and p.sub info g() when we check if a user belongs to a group? if a user do not belong to a group just return faild?

Hi, mmaotai. I haven't dived into the source code of Casbin yet but my instinct tells me that you're right.

maxwellhertz avatar Jan 21 '20 14:01 maxwellhertz

@mmaotai you are right. See the docs: https://casbin.org/docs/en/rbac

hsluoyz avatar Jan 21 '20 14:01 hsluoyz

@mmaotai you are right. See the docs: casbin.org/docs/en/rbac

I have to say, its documents are really unfriendly.

It's a great tool, Can you write the document and the case more clearly?

txjjjjj avatar Jan 22 '20 01:01 txjjjjj

@mmaotai can you describe which part of docs needs to be improved.

hsluoyz avatar Jan 22 '20 02:01 hsluoyz