pub struct ContextBuilder { /* private fields */ }Expand description
Enhanced context builder for authorization decisions
Implementations§
Source§impl ContextBuilder
impl ContextBuilder
Sourcepub fn with_trusted_proxies(self, proxies: Vec<IpAddr>) -> Self
pub fn with_trusted_proxies(self, proxies: Vec<IpAddr>) -> Self
Declare the reverse proxies in front of the server (by the address they connect
from). The client address in the context is the connection’s peer address; only when
the peer is one of these is X-Forwarded-For consulted (rightmost entry that is not
itself a trusted proxy). Without this, forwarding headers are ignored.
The peer address comes from axum’s ConnectInfo<SocketAddr>: serve the router with
into_make_service_with_connect_info::<SocketAddr>(), or no client address is known.
Sourcepub fn with_business_hours(self, start: u8, end: u8) -> Self
pub fn with_business_hours(self, start: u8, end: u8) -> Self
Configure business hours
Sourcepub fn with_corporate_networks(self, networks: Vec<IpNetwork>) -> Self
pub fn with_corporate_networks(self, networks: Vec<IpNetwork>) -> Self
Add corporate network ranges
Sourcepub fn with_holidays(self, holidays: Vec<NaiveDate>) -> Self
pub fn with_holidays(self, holidays: Vec<NaiveDate>) -> Self
Add holiday dates
Sourcepub fn build_context(
&self,
request: &Request,
auth_token: &AuthToken,
) -> AuthorizationContext
pub fn build_context( &self, request: &Request, auth_token: &AuthToken, ) -> AuthorizationContext
Build authorization context from request and auth token
Sourcepub fn to_hashmap(
&self,
context: &AuthorizationContext,
) -> HashMap<String, String>
pub fn to_hashmap( &self, context: &AuthorizationContext, ) -> HashMap<String, String>
Convert context to HashMap for role-system compatibility
Sourcepub fn enrich_context(
&self,
context: AuthorizationContext,
) -> AuthorizationContext
pub fn enrich_context( &self, context: AuthorizationContext, ) -> AuthorizationContext
Enrich existing context with additional computed attributes
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ContextBuilder
impl RefUnwindSafe for ContextBuilder
impl Send for ContextBuilder
impl Sync for ContextBuilder
impl Unpin for ContextBuilder
impl UnsafeUnpin for ContextBuilder
impl UnwindSafe for ContextBuilder
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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