pub struct Principal {
pub id: String,
pub name: String,
pub kind: PrincipalKind,
pub created: UnixMillis,
}Expand description
Someone, or something, that can authenticate.
There are no OS users. The server has no /etc/passwd, no home
directories and no authorized_keys; this table is the entire identity
system (the ACL model).
Fields§
§id: StringStable identifier, used as the key everywhere else. Same character rules as a namespace, so it can never be mistaken for a path.
It is also the account: the namespace this principal intrinsically
owns (AuthTable::owns_account), the
key a gate is filed under, and what a policy file’s
allowed_principals names. Chosen once, at creation, and never moved.
Everything that may change about a principal changes in name.
name: StringDisplay name, for humans and for UIs.
Not the identity. It defaults to the id and it may be changed
(AuthTable::rename_principal)
without touching a key, a grant, a membership, a gate or the namespace.
It is unique on the table by construction — see the names index in
AuthTable — and may not equal another principal’s
id either, so a listing never shows two rows a human reads as one.
kind: PrincipalKindWhat kind of identity this is.
created: UnixMillisWhen the row was created, by the table’s clock, in unix milliseconds.
Stamped by AuthTable::add_principal
— one writer — and 0 for a row from before the field existed, which is
what the wire reported for every principal until then. A caller that
pins a principal by (id, created) can tell a delete-and-recreate under
the same id from the row it first saw; the id alone cannot say, because
an account slug is claimable again once its account is purged.
Implementations§
Source§impl Principal
impl Principal
Sourcepub fn new(
id: impl Into<String>,
name: impl Into<String>,
kind: PrincipalKind,
) -> Result<Self>
pub fn new( id: impl Into<String>, name: impl Into<String>, kind: PrincipalKind, ) -> Result<Self>
Validate an id and build a principal.
Refuses ANONYMOUS_PRINCIPAL_ID: the anonymous identity is not
something an operator registers, and a registered principal wearing that
name would be handed the public-read rule of
AuthTable::may for free.
Sourcepub fn anonymous() -> Self
pub fn anonymous() -> Self
Nobody. The principal an unauthenticated caller is served as.
Built directly rather than through Principal::new, which refuses the
reserved id. There is no other constructor for it and no way to store
one, so every value of this shape in the process came from here.
Sourcepub fn is_anonymous(&self) -> bool
pub fn is_anonymous(&self) -> bool
Is this the anonymous principal?
By id, not by kind. The id is what
AuthTable::may is keyed on and what a grant
would name; a kind that disagreed with the id would be the twinning
this whole design avoids.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Principal
impl<'de> Deserialize<'de> for Principal
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Principal
impl StructuralPartialEq for Principal
Auto Trait Implementations§
impl Freeze for Principal
impl RefUnwindSafe for Principal
impl Send for Principal
impl Sync for Principal
impl Unpin for Principal
impl UnsafeUnpin for Principal
impl UnwindSafe for Principal
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.