Giter Site home page Giter Site logo

Comments (13)

dwang7 avatar dwang7 commented on May 12, 2024 1

@Slind14
@hsluoyz
@nodece

Can you explain why this isn't supported?

I created this model file and it seems to work fine.

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

[policy_definition]
p = sub, obj, act

[role_definition]
g = _, _, _

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

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

============================================================

p, read_role, data1, read
p, read_role, data2, read
p, write_role, data1, write
p, write_role, data2, write

g, alice, read_role, pepsi
g, alice, write_role, coke

============================================

domain is assigned in the group and not in the policy.

Enforcement works with this model.

from node-casbin.

hsluoyz avatar hsluoyz commented on May 12, 2024

Can you give more users/groups/domains in your example, like 2 or 3. I can't definitely tell what you are trying to do with only one user and one domain.

from node-casbin.

Slind14 avatar Slind14 commented on May 12, 2024

Sure, is this better to understand?

p, group_admin, subject_blog, permission_* # groups are defined on a global scope without domain relation
p, group_manager, subject_blog, permission_write
p, group_guest, subject_blog, permission_read

g, group_manager, group_guest # manager inherits guest permissions

g, user_a, group_admin, domain_7 # groups are assigned on domain level
g, user_b, group_admin, domain_3
g, user_c, group_guest, domain_3
g, user_d, group_user, domain_1

from node-casbin.

nodece avatar nodece commented on May 12, 2024

@Slind14 casbin does not support this.

from node-casbin.

nodece avatar nodece commented on May 12, 2024

@dwang7 I apologize for my answer, you are right.

from node-casbin.

dwang7 avatar dwang7 commented on May 12, 2024

@nodece

Thanks for the confirmation.

One question. Is it possible to define a domain group and reference that domain group in the role?

ie:

my_domains: (pepsi, coke, sprite)

g, alice, read_role, my_domains

how would I do this in casbin?

If not, any pointers on how and where to implement this functionality?

from node-casbin.

nodece avatar nodece commented on May 12, 2024

@dwang7 Awesome! You can do that, this is something I didn't expect 👍

from node-casbin.

dwang7 avatar dwang7 commented on May 12, 2024

@dwang7 Awesome! You can do that, this is something I didn't expect 👍

@nodece so you're saying its not possible to do this currently?

from node-casbin.

nodece avatar nodece commented on May 12, 2024

@dwang7 I mean you can do that, this is a good idea.

from node-casbin.

hsluoyz avatar hsluoyz commented on May 12, 2024

@dwang7 please raise a new GitHub issue for a new question.

from node-casbin.

dwang7 avatar dwang7 commented on May 12, 2024

@dwang7 I mean you can do that, this is a good idea.

@nodece
@hsluoyz

adding domain_groups feature to pycasbin in a forked repo

dwang7/pycasbin@c0d537d

from node-casbin.

hsluoyz avatar hsluoyz commented on May 12, 2024

@dwang7 great to see it! Can you explain how it works and even make a PR to the official repo?

from node-casbin.

dwang7 avatar dwang7 commented on May 12, 2024

@hsluoyz

This is just an initial commit. Wanted to get some feedback on my implementation. Its not optimized for large data sets yet.

Basically, I've added a new ptype, d, which is domain_groups.

https://github.com/dwang7/pycasbin/blob/master/examples/rbac_with_domain_groups_model.conf
https://github.com/dwang7/pycasbin/blob/master/examples/rbac_with_domain_groups_policy.csv

When you add to the roles, g, you can specify the domain_group instead of the domain.

g, bob, read_role, beverages

d, pepsi, beverages
d, coke, beverages
d, sprite, beverages

from node-casbin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.