pub struct AuthContext {
pub principal: String,
pub method: AuthMethod,
pub claims: HashMap<String, Value>,
pub admin: bool,
pub roles: Vec<String>,
pub namespaces: Vec<String>,
}Expand description
Authentication context attached to each request.
Fields§
§principal: StringThe principal name (e.g., key name, JWT subject, certificate CN).
method: AuthMethodWhich authentication method was used.
claims: HashMap<String, Value>Additional claims from JWT (empty for API key / mTLS).
admin: boolWhether this credential may perform administrative operations.
Carried on the credential rather than derived from a policy engine, because the policy engine is optional and “no policy” must not mean “everyone is an admin”.
roles: Vec<String>Cedar roles this credential carries, as Chronix::Role memberships.
Resolved once, here, from whichever credential authenticated —
a key’s roles list or the JWT claim named by auth.jwt.role_claim.
They used to be re-derived inside the administrative gate alone, so
the same role granted an admin operation and matched nothing in a
namespace policy, and an API key had no roles at all: every policy in
the documentation is written principal in Chronix::Role::"…".
namespaces: Vec<String>Namespaces this credential may act in; empty means unrestricted.
Authentication answers who is calling; this answers whose data they may touch. Keeping the second on the credential is what stops a valid key from reading another tenant simply by changing a header.
Implementations§
Source§impl AuthContext
impl AuthContext
Sourcepub fn allows_namespace(&self, namespace: &str) -> bool
pub fn allows_namespace(&self, namespace: &str) -> bool
Whether this credential may act in namespace.
Sourcepub fn principal(&self) -> ChronixPrincipal
pub fn principal(&self) -> ChronixPrincipal
The Cedar principal for this credential.
The only producer. Every gate builds its principal from here, so none of them can be looking at a different identity or a different role set from the others.
Trait Implementations§
Source§impl Clone for AuthContext
impl Clone for AuthContext
Source§fn clone(&self) -> AuthContext
fn clone(&self) -> AuthContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for AuthContext
impl RefUnwindSafe for AuthContext
impl Send for AuthContext
impl Sync for AuthContext
impl Unpin for AuthContext
impl UnsafeUnpin for AuthContext
impl UnwindSafe for AuthContext
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,
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