Skip to content

Add grouping policies to server response for RBAC multi-role support#302

Open
Copilot wants to merge 4 commits intomasterfrom
copilot/add-multiple-roles-support
Open

Add grouping policies to server response for RBAC multi-role support#302
Copilot wants to merge 4 commits intomasterfrom
copilot/add-multiple-roles-support

Conversation

Copy link
Contributor

Copilot AI commented Feb 1, 2026

Casbin.js already supports users with multiple roles via casbin-core's RBAC enforcer, but the test server wasn't returning grouping policies (g rules), making it appear unsupported.

Changes

  • Server: Modified CasbinService.getEnforcerConfig() to include grouping policies alongside regular policies in API responses
  • Tests: Added test case demonstrating multi-role scenarios (user with both admin and editor roles)
  • Documentation: Added RBAC section to README with backend response format example

Backend Response Format

Backends using auto mode must return both policy and grouping rules:

{
  "m": "<model configuration>",
  "p": [
    ["p", "admin", "data1", "read"],
    ["p", "editor", "data2", "read"],
    ["g", "alice", "admin"],    // Role assignment
    ["g", "alice", "editor"]    // Multiple roles per user
  ]
}

This establishes the correct pattern for implementing Casbin backends that support multiple roles per user.

Original prompt

This section details on the original issue you should resolve

<issue_title>[feature] Is Casbin.js not supported for scenarios where a user has multiple roles, meaning it hasn’t been adapted/implemented yet?</issue_title>
<issue_description>required by: casbin/casbin#1295 (comment)

@jayddzjh</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@nomeguy nomeguy marked this pull request as ready for review February 1, 2026 09:48
Copilot AI and others added 3 commits February 1, 2026 09:53
Co-authored-by: nomeguy <85475922+nomeguy@users.noreply.github.com>
Co-authored-by: nomeguy <85475922+nomeguy@users.noreply.github.com>
…aming

Co-authored-by: nomeguy <85475922+nomeguy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for multiple roles in Casbin.js Add grouping policies to server response for RBAC multi-role support Feb 1, 2026
Copilot AI requested a review from nomeguy February 1, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] Is Casbin.js not supported for scenarios where a user has multiple roles, meaning it hasn’t been adapted/implemented yet?

3 participants