Files
upstream-casbin/examples/rbac_with_abac_rule_policy.csv
upstream-mirror d8971e16fb
Some checks failed
Build / test (1.21) (push) Successful in 2m21s
Build / benchmark (1.21) (push) Failing after 2m28s
golangci-lint / golangci (push) Successful in 19m40s
snapshot of https://github.com/casbin/casbin.git (master, 2026-09-15; blobs > 131072B omitted)
2026-09-15 21:46:19 +05:00

21 lines
821 B
CSV

# RBAC roles combined with a per-policy ABAC condition.
#
# p, role, object, action, cond, effect
#
# "cond" is a matcher expression evaluated against the ctx argument of the
# request. Write "true" for a policy that carries no condition. A cond may only
# read attributes that every request reaching it actually supplies: reading an
# attribute the ctx does not have makes Enforce return an error rather than a
# plain "denied", so pass a struct (or a map with every attribute filled in).
p, employee, data1, read, r.ctx.Hour >= 9 && r.ctx.Hour < 18, allow
p, employee, data2, write, r.ctx.Secure == true, allow
p, admin, data3, read, true, allow
# Deny overrides every allow above: a high-risk session gets nothing.
p, employee, *, *, r.ctx.Risk == 'high', deny
g, admin, employee
g, alice, admin
g, bob, employee