pub struct CsrfTokenNames { /* private fields */ }Expand description
Cookie and header names used by the double-submit token check.
Services that share a browser origin should configure service-specific names during startup to
avoid cookie/header collisions. Store this value in the product’s startup state, app data, or a
process-wide OnceLock; do not switch names while a process is serving traffic because active
browser sessions would still hold the previous cookie name and frontend code may still send the
previous header.
Implementations§
Source§impl CsrfTokenNames
impl CsrfTokenNames
Sourcepub fn new(
cookie_name: impl Into<String>,
header_name: impl AsRef<str>,
) -> Result<Self>
pub fn new( cookie_name: impl Into<String>, header_name: impl AsRef<str>, ) -> Result<Self>
Builds CSRF token names after validating the cookie and header names.
Cookie names are validated against the conservative RFC 6265 token character set. Header names are parsed through Actix’s HTTP header type and are stored in canonical lower-case form, which makes comparisons and CORS allow-list generation stable.
Returns the configured CSRF cookie name.
Sourcepub fn header_name(&self) -> &HeaderName
pub fn header_name(&self) -> &HeaderName
Returns the configured CSRF request header name.
Sourcepub fn header_name_str(&self) -> &str
pub fn header_name_str(&self) -> &str
Returns the configured CSRF request header name as a lower-case string.
This is useful when building Access-Control-Allow-Headers values for browser preflight
responses.
Trait Implementations§
Source§impl Clone for CsrfTokenNames
impl Clone for CsrfTokenNames
Source§fn clone(&self) -> CsrfTokenNames
fn clone(&self) -> CsrfTokenNames
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CsrfTokenNames
impl Debug for CsrfTokenNames
Source§impl Default for CsrfTokenNames
impl Default for CsrfTokenNames
Source§impl PartialEq for CsrfTokenNames
impl PartialEq for CsrfTokenNames
Source§fn eq(&self, other: &CsrfTokenNames) -> bool
fn eq(&self, other: &CsrfTokenNames) -> bool
self and other values to be equal, and is used by ==.impl Eq for CsrfTokenNames
impl StructuralPartialEq for CsrfTokenNames
Auto Trait Implementations§
impl !Freeze for CsrfTokenNames
impl RefUnwindSafe for CsrfTokenNames
impl Send for CsrfTokenNames
impl Sync for CsrfTokenNames
impl Unpin for CsrfTokenNames
impl UnsafeUnpin for CsrfTokenNames
impl UnwindSafe for CsrfTokenNames
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.