Usage Control (UCON)
Overview
UCON (Usage Control) extends access control with authorizations (A), obligations (B), and conditions (C). It supports continuous enforcement during use (not only at access time) and mutable attributes. Casbin does not implement UCON in the core; use the casbin-ucon extension for session-based usage control.
Model & Policy
Note: Casbin does not support UCON directly in its core library. Instead, UCON functionality is provided through the extension library casbin-ucon, which adds session-based access control with conditions, obligations, and continuous monitoring capabilities. The extension can use the same models and policies supported by the Casbin core.
model
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = r.sub == p.sub && r.obj == p.obj && r.act == p.act
นโยบาย
p, alice, document1, read
Note: In UCON, Conditions and Obligations are not written in policy.csv; they are added and managed in code through the casbin-ucon API.
Core components
- Authorizations (A) — Access rules based on subject/object attributes (like standard Casbin).
- Obligations (B) — Actions the subject must perform before or during use (e.g. log, confirm).
- Conditions (C) — Environment or system state (e.g. time, location) that must hold.
Features
- Continuous enforcement — Checks during the whole usage session, not only at entry.
- Mutability — Attributes can change as a result of usage.
- Pre / ongoing / post — Decisions and obligations at access time, during use, and after.