#[non_exhaustive]pub enum Subject {
Account(String),
Person(String),
Group(String),
AnySignedIn,
}Expand description
One account, person or group, written account:<name>, person:<id> or group:<name>, or
every signed-in person, written any:signed-in.
It is the text form policies store; matches says whether a
directory’s Person is the one it names. Debug shows the kind only, since the value
is an identity; any:signed-in names nobody, so it shows whole.
use coqui_access::{Person, Subject};
let staff: Subject = "group:staff".parse()?;
let person = Person { groups: vec!["staff".into()], ..Person::default() };
assert!(staff.matches(&person));
assert_eq!(staff.to_string(), "group:staff");
let signed_in: Subject = "any:signed-in".parse()?;
assert!(signed_in.matches(&Person { id: "p-1".into(), ..Person::default() }));
assert!(!signed_in.matches(&Person::default()));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Account(String)
The person whose Person::name is this.
Person(String)
The person whose Person::id is this.
Group(String)
Every person whose Person::groups holds this, compared without regard to case: a
directory may report a group in either case, and two groups that differ only in case are
one.
AnySignedIn
Every person who carries an identity: a non-empty Person::id. An anonymous caller
has none, so it never matches. It is the only reserved any: name.
Implementations§
Source§impl Subject
impl Subject
Sourcepub fn kind(&self) -> &'static str
pub fn kind(&self) -> &'static str
The kind as written before the colon: account, person, group or any.
Sourcepub fn value(&self) -> &str
pub fn value(&self) -> &str
The name, id or group after the colon (signed-in for any:signed-in).
Sourcepub fn matches(&self, person: &Person) -> bool
pub fn matches(&self, person: &Person) -> bool
Whether person is the one this names, is in the group it names, or, for
any:signed-in, has an id.
An account name and a person id compare exactly. A group compares by Unicode lowercase,
so group:Domain Users names domain users; two POSIX groups that differ only in case
are therefore one here. == on a Subject stays exact, since it compares the text.