pub struct CookieIdentityPolicy(/* private fields */);Expand description
Use cookies for request identity storage.
The constructors take a key as an argument. This is the private key for cookie - when this value is changed, all identities are lost. The constructors will panic if the key is less than 32 bytes in length.
§Example
use actix_web::App;
use actix_identity::{CookieIdentityPolicy, IdentityService};
let app = App::new().wrap(IdentityService::new(
// <- create identity middleware
CookieIdentityPolicy::new(&[0; 32]) // <- construct cookie policy
.domain("www.rust-lang.org")
.name("actix_auth")
.path("/")
.secure(true),
));Implementations§
Source§impl CookieIdentityPolicy
impl CookieIdentityPolicy
Sourcepub fn new(key: &[u8]) -> CookieIdentityPolicy
pub fn new(key: &[u8]) -> CookieIdentityPolicy
Construct new CookieIdentityPolicy instance.
Panics if key length is less than 32 bytes.
Sourcepub fn path<S>(self, value: S) -> CookieIdentityPolicy
pub fn path<S>(self, value: S) -> CookieIdentityPolicy
Sets the path field in the session cookie being built.
Sourcepub fn name<S>(self, value: S) -> CookieIdentityPolicy
pub fn name<S>(self, value: S) -> CookieIdentityPolicy
Sets the name field in the session cookie being built.
Sourcepub fn domain<S>(self, value: S) -> CookieIdentityPolicy
pub fn domain<S>(self, value: S) -> CookieIdentityPolicy
Sets the domain field in the session cookie being built.
Sourcepub fn secure(self, value: bool) -> CookieIdentityPolicy
pub fn secure(self, value: bool) -> CookieIdentityPolicy
Sets the secure field in the session cookie being built.
If the secure field is set, a cookie will only be transmitted when the
connection is secure - i.e. https
Sourcepub fn max_age(self, seconds: i64) -> CookieIdentityPolicy
pub fn max_age(self, seconds: i64) -> CookieIdentityPolicy
Sets the max-age field in the session cookie being built with given number of seconds.
Sourcepub fn max_age_time(self, value: Duration) -> CookieIdentityPolicy
pub fn max_age_time(self, value: Duration) -> CookieIdentityPolicy
Sets the max-age field in the session cookie being built with time::Duration.
Sourcepub fn http_only(self, http_only: bool) -> CookieIdentityPolicy
pub fn http_only(self, http_only: bool) -> CookieIdentityPolicy
Sets the http_only field in the session cookie being built.
Sourcepub fn same_site(self, same_site: SameSite) -> CookieIdentityPolicy
pub fn same_site(self, same_site: SameSite) -> CookieIdentityPolicy
Sets the same_site field in the session cookie being built.
Sourcepub fn visit_deadline(self, value: Duration) -> CookieIdentityPolicy
pub fn visit_deadline(self, value: Duration) -> CookieIdentityPolicy
Accepts only users whose cookie has been seen before the given deadline
By default visit deadline is disabled.
Sourcepub fn login_deadline(self, value: Duration) -> CookieIdentityPolicy
pub fn login_deadline(self, value: Duration) -> CookieIdentityPolicy
Accepts only users which has been authenticated before the given deadline
By default login deadline is disabled.
Trait Implementations§
Source§impl IdentityPolicy for CookieIdentityPolicy
impl IdentityPolicy for CookieIdentityPolicy
Source§fn from_request(
&self,
req: &mut ServiceRequest,
) -> <CookieIdentityPolicy as IdentityPolicy>::Future
fn from_request( &self, req: &mut ServiceRequest, ) -> <CookieIdentityPolicy as IdentityPolicy>::Future
Source§fn to_response<B>(
&self,
id: Option<String>,
changed: bool,
res: &mut ServiceResponse<B>,
) -> <CookieIdentityPolicy as IdentityPolicy>::ResponseFuture
fn to_response<B>( &self, id: Option<String>, changed: bool, res: &mut ServiceResponse<B>, ) -> <CookieIdentityPolicy as IdentityPolicy>::ResponseFuture
Auto Trait Implementations§
impl Freeze for CookieIdentityPolicy
impl RefUnwindSafe for CookieIdentityPolicy
impl !Send for CookieIdentityPolicy
impl !Sync for CookieIdentityPolicy
impl Unpin for CookieIdentityPolicy
impl UnwindSafe for CookieIdentityPolicy
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more