Skip to content
Discussion options

You must be logged in to vote

Casbin has the pieces for this built in: read the policy before and after, apply the change through the management API, and use enforce_ex (EnforceEx in Go) as the evidence, since it returns the decision and the policy rule that produced it. Here's a minimal, self-contained example with pycasbin (1.43.0):

import copy, json
from datetime import datetime, timezone
import casbin

# model.conf: RBAC (r = sub, obj, act; g = _, _; m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act)
# policy.csv:
#   p, editor, report, write
#   g, alice, viewer
e = casbin.Enforcer("model.conf", "policy.csv")
request = ("alice", "report", "write")

def snapshot():
    # get_policy()/get_grouping_policy() re…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by hsluoyz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants