Skip to content

feat: add examples for RBAC combined with ABAC context rules#1735

Open
AlabLan wants to merge 2 commits into
apache:masterfrom
AlabLan:dev
Open

feat: add examples for RBAC combined with ABAC context rules#1735
AlabLan wants to merge 2 commits into
apache:masterfrom
AlabLan:dev

Conversation

@AlabLan

@AlabLan AlabLan commented Jun 11, 2026

Copy link
Copy Markdown

Add model, policy and request example files demonstrating how context-based ABAC rules can be layered on top of RBAC roles in a single combined model.

AlabLan added 2 commits June 11, 2026 11:08
Add model, policy and request example files demonstrating how context-based ABAC rules can be layered on top of RBAC roles in a single combined model.
Add TestRBACWithABACRule covering RBAC roles combined with per-request ABAC
context rules, mirroring the jcasbin test. The matcher evaluates p.ctx_rule
as a per-request allow/deny filter against the request ctx.

Switch the example policy to single-quoted string literals so it parses under
Go's stricter encoding/csv reader, which rejects bare double quotes. The
single-quoted form is also valid in jcasbin's govaluate, so the example stays
cross-compatible.

Because Go's govaluate errors on missing map keys (unlike jcasbin's lenient
evaluator), the test uses a neutral ctx that supplies every ctx_rule field
with a non-matching value for the no-special-context cases.
@AlabLan

AlabLan commented Jun 22, 2026

Copy link
Copy Markdown
Author

I have already added the corresponding test code. Here is the link to the online editor: https://editor.casbin.org/#EN25Q5ZZC

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.

1 participant