pub struct ConnectionContext {
pub remote_addr: Option<SocketAddr>,
pub metadata: HashMap<String, Arc<dyn Any + Send + Sync>>,
}Expand description
Connection context for authentication
This struct holds metadata about a connection that can be used for
authentication and authorization decisions. The library makes NO
assumptions about what data you need - store anything in metadata.
§Examples
- TLS client certificates
- IP addresses for whitelisting
- Custom connection-level tokens
- Session identifiers
Fields§
§remote_addr: Option<SocketAddr>Remote address of the connection
metadata: HashMap<String, Arc<dyn Any + Send + Sync>>User-defined metadata
Store any auth-related data here:
- TLS peer certificates
- Extracted user IDs
- Session tokens
- Rate limiting state
- Whatever you need for your auth logic
Implementations§
Source§impl ConnectionContext
impl ConnectionContext
Sourcepub fn with_addr(remote_addr: SocketAddr) -> Self
pub fn with_addr(remote_addr: SocketAddr) -> Self
Create context with remote address
Trait Implementations§
Source§impl Clone for ConnectionContext
impl Clone for ConnectionContext
Source§fn clone(&self) -> ConnectionContext
fn clone(&self) -> ConnectionContext
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 moreSource§impl Default for ConnectionContext
impl Default for ConnectionContext
Source§fn default() -> ConnectionContext
fn default() -> ConnectionContext
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ConnectionContext
impl !RefUnwindSafe for ConnectionContext
impl Send for ConnectionContext
impl Sync for ConnectionContext
impl Unpin for ConnectionContext
impl !UnwindSafe for ConnectionContext
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