pub struct Principal {
pub user_id: Uuid,
pub organizations: Vec<OrgMembership>,
}Expand description
The authenticated caller behind a request.
Fields§
§user_id: Uuid§organizations: Vec<OrgMembership>Organisations the caller belongs to (loaded per request). Drives all
org-scoped access and role: checks.
Implementations§
Source§impl Principal
impl Principal
Sourcepub fn membership(&self, org: Uuid) -> Option<&OrgMembership>
pub fn membership(&self, org: Uuid) -> Option<&OrgMembership>
Membership in a specific organisation, if any.
Sourcepub fn role_in(&self, org: Uuid) -> Option<&str>
pub fn role_in(&self, org: Uuid) -> Option<&str>
The caller’s primary role within org, if any.
This is what a hook context’s role reports. Authorization asks
has_role_in instead, because holding a role is
not the same as it being your headline one.
Sourcepub fn has_role_in(&self, org: Uuid, role: &str) -> bool
pub fn has_role_in(&self, org: Uuid, role: &str) -> bool
Whether the caller may act as role in org. The question every
role: permission asks.
Sourcepub fn is_admin_of(&self, org: Uuid) -> bool
pub fn is_admin_of(&self, org: Uuid) -> bool
Whether the caller administers org.
Sourcepub fn org_ids_with_role(&self, role: &str) -> Vec<Uuid>
pub fn org_ids_with_role(&self, role: &str) -> Vec<Uuid>
Organisations where the caller may act as role — including the ones
they merely administer.
Trait Implementations§
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§
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
Mutably borrows from an owned value. Read more
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,
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
Compare self to
key and return true if they are equal.