Struct actix_identity::CookieIdentityPolicy[][src]

pub struct CookieIdentityPolicy(_);
Expand description

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

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..

Sets the name of issued cookies.

Sets the Path attribute of issued cookies.

Sets the Domain attribute of issued cookies.

Sets the Secure attribute of issued cookies.

Sets the Max-Age attribute of issued cookies.

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

Sets the HttpOnly attribute of issued cookies.

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

Sets the SameSite attribute of issued cookies.

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

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.

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

The return type of the middleware

The return type of the middleware

Parse the session from request and load data from a service identity.

Write changes to response

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.