Struct actix_identity::CookieIdentityPolicy [−][src]
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
fn from_request(&self, req: &mut ServiceRequest) -> Self::Future
[src]
fn to_response<B>(
&self,
id: Option<String>,
changed: bool,
res: &mut ServiceResponse<B>
) -> Self::ResponseFuture
[src]
&self,
id: Option<String>,
changed: bool,
res: &mut ServiceResponse<B>
) -> Self::ResponseFuture
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,