question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom RoleManager

See original GitHub issue

Hello. In this doc page, the maintainers of Casbin seem to imply that you can choose/write your own RoleManager class. However, this seems to be hardcoded in. Is there a way to supply a custom class? Can one be made with relative ease?

https://github.com/casbin/pycasbin/blob/a915dce5d7d0707f98a91c3677ef47a8d6ce6cd2/casbin/core_enforcer.py#L65-L72

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
hsluoyzcommented, Dec 10, 2019

set_role_manager() should be called before adding g policy rules.

0reactions
hameerabbasicommented, Dec 10, 2019
    m = casbin.model.Model()
    m.add_def("r", "r", "sub, obj, act")
    m.add_def("p", "p", "sub, obj, act")
    m.add_def("g", "g", "_, _")
    m.add_def("e", "e", "some(where (p.eft == allow))")
    m.add_def("m", "m", "g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act")

    a = db.Adapter(postgresql_engine)
    a.add_policy("p", "p", ["alice", "data1", "read"])
    a.add_policy("p", "p", ["bob", "data2", "write"])
    e = casbin.Enforcer(m, a)
    e.set_role_manager(db.MyRoleManager())

Will alice and bob make it into roles?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating Custom Role Manager In ASP.NET MVC 5
In this article, we are going to learn how to create and use custom role manager in ASP.NET MVC in a step-by-step way....
Read more >
Custom Role Manager / Provider - Stack Overflow
I am trying to implement a custom role manager in an MVC5 application using the following Custom Role Provider Tutorial.
Read more >
Customize the RoleManager and create users - MSDN
Hi, I implemented the RoleManager in my asp.net site. But I want to customize the aspnet_Users_CreateUser stored procedure to accept Email ...
Read more >
ASP.NET MVC 5 Custom Role Providers for Windows ...
How to create a custom role provider and custom authorize attribute in ASP. ... the application to use our new custom role provider...
Read more >
Custom User Management in ASP.NET Core MVC with Identity
This will invoke the Method that seeds the default user to the database. await ContextSeed.SeedSuperAdminAsync(userManager, roleManager) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found