Skip to main content

Crate coqui_roles

Crate coqui_roles 

Source
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.
RoleAuthorizer
First-match role authorizer, and the coqui_roles provider, configured with a RolePolicy.
RoleAuthorizerBuilder
Builds a RoleAuthorizer; rules are tried in the order they are added.
RoleLimits
Bounds on a policy, each a [Limit] the caller can change or lift ([Limit::UNBOUNDED]).
RolePolicy
A role policy as plain data: what RoleAuthorizer::new checks and compiles.
RolePolicyError
An invalid role policy.
Rule
Binds a subject to a role at a scope.

Traits§

RoleLimitsSetters
The typed setters of RoleLimits, for any builder that holds its settings.
RolePolicySetters
The typed setters of RolePolicy, for any builder that holds its settings.
RoleSetters
The typed setters of Role, for any builder that holds its settings.
RuleSetters
The typed setters of Rule, for any builder that holds its settings.