Skip to main content

Principal

Struct Principal 

Source
pub struct Principal {
    pub user: User,
    pub kind: PrincipalKind,
    pub orgs: Vec<(OrgId, Role)>,
    pub platform_admin: bool,
    pub downscoped: Option<OrgId>,
}
Expand description

An authenticated caller: who, how, and what they may reach. For an org-scoped token, orgs is that one org and platform_admin is false whatever the user is.

Fields§

§user: User§kind: PrincipalKind§orgs: Vec<(OrgId, Role)>§platform_admin: bool§downscoped: Option<OrgId>

Set on an org-bound endpoint for a superadmin or platform admin: an admin of this org only.

Implementations§

Source§

impl Principal

Source

pub fn scopes(&self) -> &[String]

The token’s scopes; empty for sessions and unscoped tokens.

Source

pub fn restricted(&self) -> bool

A token scoped short of admin: it may not change who has access.

Source

pub fn downscoped_to(&self, org: &OrgId) -> Principal

This principal as an org-bound endpoint sees it. A superadmin or a platform admin becomes an admin of org only (an owner stays one): not a platform admin, no other org. Everyone else is unchanged.

Source

pub fn workspace(org: &OrgId, name: &str, role: Role) -> Principal

The principal an org’s workspace token authenticates: no account (user id 0, named workspace), confined to org with role.

Source

pub fn is_workspace(&self) -> bool

An org’s workspace, rather than a person or a user’s token.

Source

pub fn agent(label: &str, orgs: Vec<(OrgId, Role)>) -> Principal

The principal of a tailnet or Access agent: no account (user id 0, named after its source), confined to orgs, never a platform admin. label is tailnet:<login or node> or access:<name>.

Source

pub fn is_agent(&self) -> bool

A tailnet or Access agent identity mapped by an org.

Source§

impl Principal

Source

pub fn is_platform_admin(&self) -> bool

Source

pub fn role_in(&self, org: &OrgId) -> Option<Role>

Source

pub fn can_admin_org(&self, org: &OrgId) -> bool

Apps, stacks, sandboxes and secrets in org.

Source

pub fn can_read_org(&self, org: &OrgId) -> bool

Read-only tools in org.

Source

pub fn can_manage_members(&self, org: &OrgId) -> bool

Members, invitations and every token in org.

Source

pub fn can_delete_org(&self, org: &OrgId) -> bool

Source

pub fn max_grant(&self, org: &OrgId) -> Option<Role>

The highest role this principal may hand out in org.

Source

pub fn session_id(&self) -> Option<i64>

Trait Implementations§

Source§

impl Clone for Principal

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Principal

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Principal

Source§

impl PartialEq for Principal

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Principal

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AnyEq for T
where T: Any + PartialEq,

Source§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V