pub struct ChronixPrincipal {
pub id: String,
pub roles: Vec<String>,
}Expand description
A Chronix principal (authenticated identity).
Built in one place — chronixd’s authentication middleware, from the
credential — so the roles a policy matches on are the same set whichever
gate asks. They used to be resolved inside the admin gate alone, so the
same role granted an administrative operation and nothing in a
namespace policy, and an API key had no roles at all.
Fields§
§id: StringThe principal identifier (an API key name, a JWT subject, a cert CN).
roles: Vec<String>Roles assigned to this principal, as Chronix::Role parents.
Implementations§
Source§impl ChronixPrincipal
impl ChronixPrincipal
Sourcepub fn with_roles<I, S>(self, roles: I) -> Self
pub fn with_roles<I, S>(self, roles: I) -> Self
Add several roles.
Sourcepub fn to_entity(&self) -> Result<Entity, AuthzError>
pub fn to_entity(&self) -> Result<Entity, AuthzError>
Convert to a Cedar entity (roles become parent entities).
§Errors
Returns AuthzError::Internal if Cedar rejects the entity.
Sourcepub fn role_entities(&self) -> Result<Vec<Entity>, AuthzError>
pub fn role_entities(&self) -> Result<Vec<Entity>, AuthzError>
The role entities this principal claims membership of.
Cedar needs them in the entity set for principal in Chronix::Role::"…" to resolve; a role with no entity is a membership
that silently does not hold.
§Errors
Returns AuthzError::Internal if Cedar rejects an entity.
Sourcepub fn to_entity_uid(&self) -> EntityUid
pub fn to_entity_uid(&self) -> EntityUid
Convert to the Cedar entity UID.
Trait Implementations§
Source§impl Clone for ChronixPrincipal
impl Clone for ChronixPrincipal
Source§fn clone(&self) -> ChronixPrincipal
fn clone(&self) -> ChronixPrincipal
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ChronixPrincipal
impl Debug for ChronixPrincipal
Source§impl<'de> Deserialize<'de> for ChronixPrincipal
impl<'de> Deserialize<'de> for ChronixPrincipal
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 ChronixPrincipal
Source§impl PartialEq for ChronixPrincipal
impl PartialEq for ChronixPrincipal
Source§impl Serialize for ChronixPrincipal
impl Serialize for ChronixPrincipal
impl StructuralPartialEq for ChronixPrincipal
Auto Trait Implementations§
impl Freeze for ChronixPrincipal
impl RefUnwindSafe for ChronixPrincipal
impl Send for ChronixPrincipal
impl Sync for ChronixPrincipal
impl Unpin for ChronixPrincipal
impl UnsafeUnpin for ChronixPrincipal
impl UnwindSafe for ChronixPrincipal
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
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§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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more