Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] - How Would I make queries for different scenarios #108

Closed
sujit-baniya opened this issue May 1, 2021 · 7 comments
Closed

[QUESTION] - How Would I make queries for different scenarios #108

sujit-baniya opened this issue May 1, 2021 · 7 comments
Assignees
Labels

Comments

@sujit-baniya
Copy link

I've been using this adapter on Postgres. Curently I'm stuck on getting some information from Casbin. Please help me understand how could I query to get those information.

I'm trying to look for

  1. If the domain is *, get all users associated to all domains with their respective roles
  2. get all users associated to a domain with their respective roles

So I have basically added three roles: admin, account-admin, and user
admin => with all powers
account-admin => with all powers for account (domain)
user => normal users

And Admin would see all users irrespective of domains, Account Admin would see all users associated with the domain.

Currently I needed to make custom queries to fetch such information. Any help would be highly appreciated.

@hsluoyz
Copy link
Member

hsluoyz commented May 1, 2021

@sujit-baniya plz use: https://casbin.org/docs/en/rbac-with-domains

It's not a gorm-adapter issue I think.

@hsluoyz hsluoyz self-assigned this May 1, 2021
@sujit-baniya
Copy link
Author

sujit-baniya commented May 1, 2021

@hsluoyz Thanks for your response. I added the extra matcher parameter but still I don't see any effect. Need to check more.

[request_definition]
r = sub, dom, obj, act

[policy_definition]
p = sub, dom, obj, act

[role_definition]
g = _, _, _

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

[matchers]
m = g(r.sub, p.sub, r.dom) && r.dom == p.dom && r.obj == p.obj && r.act == p.act || r.sub == root

@hsluoyz
Copy link
Member

hsluoyz commented May 2, 2021

@sujit-baniya
Copy link
Author

sujit-baniya commented May 3, 2021

@hsluoyz Thanks again :). I tried and now I could get all Domains associated with the Admin account using following Model.

[request_definition]
r = sub, dom, obj, act

[policy_definition]
p = sub, dom, obj, act

[role_definition]
g = _, _, _

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

[matchers]
m = g(r.sub, p.sub, r.dom) && keyMatch2(r.dom, p.dom) && r.obj == p.obj && r.act == p.act

Still casbin is not providing any API for getting all users for a Domain. Creating one issue on Casbin.

@sujit-baniya
Copy link
Author

@hsluoyz Here, casbin/casbin#782

@sujit-baniya
Copy link
Author

Also can you please suggest which storage would be best for high performance: CSV vs POstgres

@hsluoyz
Copy link
Member

hsluoyz commented May 3, 2021

@sujit-baniya DB adapter is better for production use.

Closed here.

@hsluoyz hsluoyz closed this as completed May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants