Expand description
A first-match role authorizer, built in code.
A policy is named roles that list actions, and ordered rules that bind one
account:<name>, person:<id> or group:<name>, or every signed-in subject
(any:signed-in), to a role at one scope. A scope is *
(everything) or <kind>:<id>, where the kinds a deployment uses are configured, for
example site or project; the library has no scope vocabulary of its own. A rule’s
scope matches a request when it is *, when it equals the request’s resource as an
exact string, or when the request names it among its ancestors and the rule propagates
(the default), so a grant on a parent reaches what sits under it.
The first rule whose subject and scope match is decisive: when its role lacks the requested action, access is denied. With no matching rule access is denied. A child narrows its parent’s grant with a rule placed before the parent’s.
use coqui_roles::{RoleAuthorizer, Rule};
let authorizer = RoleAuthorizer::builder()
.scope_kinds(["site"])
.role("viewer", ["document.read"])
.rule(Rule::new("group:staff", "site:north", "viewer"))
.build()
.unwrap();RolePolicy is the same thing as plain data with guatiao’s value traits, so a caller
keeps it in any format; it is also the configuration RoleAuthorizer takes as the
coqui_roles provider, which coqui-roles-plugin exports.
Structs§
- Role
- A named set of actions.
- Role
Authorizer - First-match role authorizer, and the
coqui_rolesprovider, configured with aRolePolicy. - Role
Authorizer Builder - Builds a
RoleAuthorizer; rules are tried in the order they are added. - Role
Limits - Bounds on a policy, each a [
Limit] the caller can change or lift ([Limit::UNBOUNDED]). - Role
Policy - A role policy as plain data: what
RoleAuthorizer::newchecks and compiles. - Role
Policy Error - An invalid role policy.
- Rule
- Binds a subject to a role at a scope.
Traits§
- Role
Limits Setters - The typed setters of
RoleLimits, for any builder that holds its settings. - Role
Policy Setters - The typed setters of
RolePolicy, for any builder that holds its settings. - Role
Setters - The typed setters of
Role, for any builder that holds its settings. - Rule
Setters - The typed setters of
Rule, for any builder that holds its settings.