Struct actix_identity::CookieIdentityPolicy[][src]

pub struct CookieIdentityPolicy(_);

Use cookies for request identity storage.

See this page on MDN for details on cookie attributes.

Examples

use actix_web::App;
use actix_identity::{CookieIdentityPolicy, IdentityService};

// create cookie identity backend
let policy = CookieIdentityPolicy::new(&[0; 32])
           .domain("www.rust-lang.org")
           .name("actix_auth")
           .path("/")
           .secure(true);

let app = App::new()
    // wrap policy into identity middleware
    .wrap(IdentityService::new(policy));

Implementations

impl CookieIdentityPolicy[src]

pub fn new(key: &[u8]) -> CookieIdentityPolicy[src]

Create new CookieIdentityPolicy instance.

Key argument is the private key for issued cookies. If this value is changed, all issued cookie identities are invalidated.

Panics

Panics if key is less than 32 bytes in length..

pub fn name(self, value: impl Into<String>) -> CookieIdentityPolicy[src]

Sets the name of issued cookies.

pub fn path(self, value: impl Into<String>) -> CookieIdentityPolicy[src]

Sets the Path attribute of issued cookies.

pub fn domain(self, value: impl Into<String>) -> CookieIdentityPolicy[src]

Sets the Domain attribute of issued cookies.

pub fn secure(self, value: bool) -> CookieIdentityPolicy[src]

Sets the Secure attribute of issued cookies.

pub fn max_age(self, value: Duration) -> CookieIdentityPolicy[src]

Sets the Max-Age attribute of issued cookies.

pub fn max_age_secs(self, seconds: i64) -> CookieIdentityPolicy[src]

Sets the Max-Age attribute of issued cookies with given number of seconds.

pub fn http_only(self, http_only: bool) -> Self[src]

Sets the HttpOnly attribute of issued cookies.

By default, the HttpOnly attribute is omitted from issued cookies.

pub fn same_site(self, same_site: SameSite) -> Self[src]

Sets the SameSite attribute of issued cookies.

By default, the SameSite attribute is omitted from issued cookies.

pub fn visit_deadline(self, deadline: Duration) -> CookieIdentityPolicy[src]

Accepts only users who have visited within given deadline.

In other words, invalidate a login after some amount of inactivity. Using this feature causes updated cookies to be issued on each response in order to record the user’s last visitation timestamp.

By default, visit deadline is disabled.

pub fn login_deadline(self, deadline: Duration) -> CookieIdentityPolicy[src]

Accepts only users who authenticated within the given deadline.

In other words, invalidate a login after some amount of time, regardless of activity. While Max-Age is useful in constraining the cookie lifetime, it could be extended manually; using this feature encodes the deadline directly into the issued cookies, making it immutable to users.

By default, login deadline is disabled.

Trait Implementations

impl IdentityPolicy for CookieIdentityPolicy[src]

type Future = Ready<Result<Option<String>, Error>>

The return type of the middleware

type ResponseFuture = Ready<Result<(), Error>>

The return type of the middleware

Auto Trait Implementations

impl !RefUnwindSafe for CookieIdentityPolicy

impl !Send for CookieIdentityPolicy

impl !Sync for CookieIdentityPolicy

impl Unpin for CookieIdentityPolicy

impl UnwindSafe for CookieIdentityPolicy

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,