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
type ResponseFuture = Ready<Result<(), Error>>
type ResponseFuture = Ready<Result<(), Error>>
The return type of the middleware
Parse the session from request and load data from a service identity.
fn to_response<B>(
&self,
id: Option<String>,
changed: bool,
res: &mut ServiceResponse<B>
) -> Self::ResponseFuture
fn to_response<B>(
&self,
id: Option<String>,
changed: bool,
res: &mut ServiceResponse<B>
) -> Self::ResponseFuture
Write changes to response
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
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more