Skip to main content

Identity

Trait Identity 

Source
pub trait Identity:
    Send
    + Sync
    + 'static {
    // Required method
    fn is_guest(&self) -> bool;

    // Provided methods
    fn csrf_binding(&self) -> Option<&[u8]> { ... }
    fn set_cookie(&self) -> Option<&str> { ... }
}
Expand description

Who is asking. A request that reaches a handler always carries one, possibly a guest.

Required Methods§

Source

fn is_guest(&self) -> bool

Whether this is a visitor with no signed-in session.

Provided Methods§

Source

fn csrf_binding(&self) -> Option<&[u8]>

The value CSRF tokens are bound to: the session id, or a pre-session id for a guest. None means no binding exists, and an unsafe method on a CSRF-protected route is refused.

A Set-Cookie value the gate wants on the reply (a dead session’s cookie cleared, a pre-session id set). App::respond writes it on every exit after authentication, once; with App::respond_identified the caller authenticated and writes its own. A reply that carries it is never reported as keepable by a cache.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§