pub enum SameSite {
Strict,
Lax,
None,
}Expand description
The SameSite attribute for cookies, providing CSRF protection.
The SameSite attribute controls when cookies are sent with cross-site requests, helping to prevent Cross-Site Request Forgery (CSRF) attacks.
§Variants
- Strict: Cookie never sent with cross-site requests
- Lax: Cookie sent with safe cross-site requests (GET, HEAD, OPTIONS, TRACE)
- None: Cookie sent with all cross-site requests (requires Secure flag)
§Examples
use ignitia::{Cookie, SameSite};
// Strict - maximum protection, may break some legitimate use cases
let strict_cookie = Cookie::new("csrf_token", "abc123")
.same_site(SameSite::Strict);
// Lax - good balance of security and usability
let lax_cookie = Cookie::new("session_id", "xyz789")
.same_site(SameSite::Lax);
// None - for cross-site functionality (must be secure)
let cross_site_cookie = Cookie::new("tracking_id", "def456")
.same_site(SameSite::None)
.secure();Variants§
Strict
Never send cookie with cross-site requests
Lax
Send cookie with safe cross-site requests only
None
Send cookie with all cross-site requests (requires Secure)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SameSite
impl RefUnwindSafe for SameSite
impl Send for SameSite
impl Sync for SameSite
impl Unpin for SameSite
impl UnwindSafe for SameSite
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