Assignments
An assignment gives a user a role in a scope. It is the only runtime data wardn needs about people:
ada → org_admin at organisation:acmebayo → teller at branch:lagostolu → loan_officer at branch:lagos from Monday until Fridayroot → super_admin at globalwardn never stores users themselves, only the IDs your authentication provides.
Making assignments
Section titled “Making assignments”// On behalf of the signed-in user (checked by the escalation guard):err := w.Assign(ctx, "bayo", "teller", wardn.NewScope("branch", "lagos"))
// With no user acting, for setup scripts and jobs:err := w.System().Assign(ctx, "root", "super_admin", wardn.Global)
// Removing:err := w.Revoke(ctx, "bayo", "teller", wardn.NewScope("branch", "lagos"))- One assignment per user, role and scope. Assigning again replaces the time window.
- Revoking is idempotent. Revoking something that isn’t there is not an error.
assignable_atis enforced: assigningtellerat an organisation fails withErrNotAssignable.
Time-limited access
Section titled “Time-limited access”Pass From and Until for access that starts or ends on its own:
err := w.Assign(ctx, "tolu", "loan_officer", lagos, wardn.From(monday), wardn.Until(friday))The window applies from From (inclusive) until Until (exclusive). It’s checked on every request, so access ends at exactly the right moment, and no cleanup job is needed for correctness. See Time-limited access.
When roles change underneath
Section titled “When roles change underneath”- If a role is removed from the policy, its assignments simply stop granting anything.
- If a role’s
assignable_atno longer allows a scope type, assignments of it there stop applying. - If a custom role is deleted, its assignments grant nothing, even before they are cleaned up.
In each case the leftover assignment is harmless and can still be revoked.
Questions about this page?
Ask below, point out something wrong or unclear, or suggest an improvement. Reading needs no account; to post, sign in with GitHub.