pub struct AuthScope {
pub allowed_namespaces: Vec<String>,
pub tenant_id: Option<String>,
pub project_id: Option<String>,
pub expires_at: Option<u64>,
pub capabilities: AuthCapabilities,
pub acl_tags: Vec<String>,
}Expand description
Authorization scope - ALWAYS conjoined with user filters
This is the security boundary that cannot be bypassed. It encodes:
- Allowed namespaces/tenants
- Optional project scope
- Token expiry
- Capability flags
Fields§
§allowed_namespaces: Vec<String>Allowed namespaces (non-empty; at least one required)
tenant_id: Option<String>Optional tenant ID (for multi-tenant deployments)
project_id: Option<String>Optional project scope
expires_at: Option<u64>Token expiry timestamp (Unix epoch seconds)
capabilities: AuthCapabilitiesCapability flags
Optional ACL tags the caller has access to
Implementations§
Source§impl AuthScope
impl AuthScope
Sourcepub fn for_namespace(namespace: impl Into<String>) -> Self
pub fn for_namespace(namespace: impl Into<String>) -> Self
Create a new auth scope for a single namespace
Sourcepub fn full_access(namespace: impl Into<String>) -> Self
pub fn full_access(namespace: impl Into<String>) -> Self
Create with full access to a namespace
Sourcepub fn with_namespace(self, namespace: impl Into<String>) -> Self
pub fn with_namespace(self, namespace: impl Into<String>) -> Self
Add a namespace to the allowed list
Sourcepub fn with_tenant(self, tenant_id: impl Into<String>) -> Self
pub fn with_tenant(self, tenant_id: impl Into<String>) -> Self
Set tenant ID
Sourcepub fn with_project(self, project_id: impl Into<String>) -> Self
pub fn with_project(self, project_id: impl Into<String>) -> Self
Set project ID
Sourcepub fn with_expiry(self, expires_at: u64) -> Self
pub fn with_expiry(self, expires_at: u64) -> Self
Set expiry
Add ACL tags
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if this scope is expired
Sourcepub fn is_namespace_allowed(&self, namespace: &str) -> bool
pub fn is_namespace_allowed(&self, namespace: &str) -> bool
Check if a namespace is allowed
Sourcepub fn to_filter_ir(&self) -> FilterIR
pub fn to_filter_ir(&self) -> FilterIR
Convert auth scope to filter IR clauses
This generates the mandatory predicates that MUST be conjoined with any user filter.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for AuthScope
impl<'de> Deserialize<'de> for AuthScope
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>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for AuthScope
Auto Trait Implementations§
impl Freeze for AuthScope
impl RefUnwindSafe for AuthScope
impl Send for AuthScope
impl Sync for AuthScope
impl Unpin for AuthScope
impl UnsafeUnpin for AuthScope
impl UnwindSafe for AuthScope
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
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>
Converts
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>
Converts
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