pub struct CsrfDoubleSubmitCookie {
pub http_only: bool,
pub secure: bool,
pub same_site: SameSite,
}
Expand description
Cookie flags for tokens when using the Double-Submit Cookie pattern.
http_only
: Must befalse
so client code can read the token and mirror it into a header or form field.secure
: Should betrue
in production to restrict cookies to HTTPS.same_site
: ChooseStrict
orLax
depending on your cross-site needs.
§Examples
use actix_csrf_middleware::{CsrfMiddlewareConfig, CsrfDoubleSubmitCookie};
use actix_web::cookie::SameSite;
let secret = b"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
let cfg = CsrfMiddlewareConfig::double_submit_cookie(secret)
.with_token_cookie_config(CsrfDoubleSubmitCookie {
http_only: false,
secure: true,
same_site: SameSite::Strict,
});
Fields§
§http_only: bool
If true, JavaScript cannot read the cookie
secure: bool
Restrict cookies to HTTPS in production
same_site: SameSite
SameSite policy controlling cross-site cookie sending
Trait Implementations§
Source§impl Clone for CsrfDoubleSubmitCookie
impl Clone for CsrfDoubleSubmitCookie
Source§fn clone(&self) -> CsrfDoubleSubmitCookie
fn clone(&self) -> CsrfDoubleSubmitCookie
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for CsrfDoubleSubmitCookie
impl RefUnwindSafe for CsrfDoubleSubmitCookie
impl Send for CsrfDoubleSubmitCookie
impl Sync for CsrfDoubleSubmitCookie
impl Unpin for CsrfDoubleSubmitCookie
impl UnwindSafe for CsrfDoubleSubmitCookie
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
Mutably borrows from an owned value. Read more