pub struct AuthContext {
pub user_id: UserId,
pub permissions: PermissionSet,
pub namespace: Option<String>,
}Expand description
Authentication context for a request
Fields§
§user_id: UserId§permissions: PermissionSet§namespace: Option<String>Implementations§
Source§impl AuthContext
impl AuthContext
Sourcepub fn new(user_id: UserId, permissions: PermissionSet) -> Self
pub fn new(user_id: UserId, permissions: PermissionSet) -> Self
Create a new auth context
Sourcepub fn with_namespace(
user_id: UserId,
permissions: PermissionSet,
namespace: String,
) -> Self
pub fn with_namespace( user_id: UserId, permissions: PermissionSet, namespace: String, ) -> Self
Create auth context with namespace
Sourcepub fn has_permission(
&self,
permission: Permission,
resource: ResourceType,
) -> bool
pub fn has_permission( &self, permission: Permission, resource: ResourceType, ) -> bool
Check if user has permission
Sourcepub fn require_permission(
&self,
permission: Permission,
resource: ResourceType,
) -> Result<()>
pub fn require_permission( &self, permission: Permission, resource: ResourceType, ) -> Result<()>
Require permission or return error
Trait Implementations§
Source§impl Clone for AuthContext
impl Clone for AuthContext
Source§fn clone(&self) -> AuthContext
fn clone(&self) -> AuthContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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 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
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 moreCreates a shared type from an unshared type.