pub struct OAuth2State(/* private fields */);Expand description
Type-safe wrapper for OAuth2 state parameters.
This provides compile-time safety to prevent mixing up OAuth2 state strings with other string types. OAuth2 state parameters are base64url-encoded JSON that carries CSRF protection and flow parameters between authorization requests and callbacks. Proper validation is critical for security.
Implementations§
Source§impl OAuth2State
impl OAuth2State
Sourcepub fn new(state: String) -> Result<Self, OAuth2Error>
pub fn new(state: String) -> Result<Self, OAuth2Error>
Creates a new OAuth2State from a string with validation.
This constructor validates the OAuth2 state format to ensure it meets security requirements for CSRF protection and parameter integrity.
§Arguments
state- The OAuth2 state string (should be base64url-encoded)
§Returns
Ok(OAuth2State)- If the state is validErr(OAuth2Error)- If the state is invalid
§Validation Rules
- Must not be empty
- Must be valid base64url encoding
- Must contain valid JSON when decoded
- Must be reasonable length
Trait Implementations§
Source§impl Clone for OAuth2State
impl Clone for OAuth2State
Source§fn clone(&self) -> OAuth2State
fn clone(&self) -> OAuth2State
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 moreSource§impl Debug for OAuth2State
impl Debug for OAuth2State
Source§impl Display for OAuth2State
impl Display for OAuth2State
Source§impl PartialEq for OAuth2State
impl PartialEq for OAuth2State
impl StructuralPartialEq for OAuth2State
Auto Trait Implementations§
impl Freeze for OAuth2State
impl RefUnwindSafe for OAuth2State
impl Send for OAuth2State
impl Sync for OAuth2State
impl Unpin for OAuth2State
impl UnwindSafe for OAuth2State
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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 moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.