pub struct PkceCodePair {
pub verifier: String,
pub challenge: String,
pub method: CodeChallengeMethod,
}Expand description
PKCE code pair for secure OAuth flows
Proof Key for Code Exchange (PKCE) prevents authorization code interception attacks. Always use S256 method for production applications.
§Example
// Generate a new PKCE code pair
let pkce = PkceCodePair::generate()?;
// Use the challenge in the authorization URL
println!("Challenge: {}", pkce.challenge);
// Store the verifier securely for token exchange
println!("Verifier: {}", pkce.verifier);Fields§
§verifier: StringCode verifier (random string, 43-128 characters)
challenge: StringCode challenge (hash of verifier)
method: CodeChallengeMethodChallenge method used
Implementations§
Source§impl PkceCodePair
impl PkceCodePair
Sourcepub fn generate() -> Result<Self, PkceError>
pub fn generate() -> Result<Self, PkceError>
Generate a new PKCE code pair using S256 method
Creates a cryptographically secure random verifier and computes the SHA-256 challenge.
§Errors
Returns an error if random number generation fails.
§Example
let pkce = PkceCodePair::generate()?;
assert!(!pkce.verifier.is_empty());
assert!(!pkce.challenge.is_empty());Trait Implementations§
Source§impl Clone for PkceCodePair
impl Clone for PkceCodePair
Source§fn clone(&self) -> PkceCodePair
fn clone(&self) -> PkceCodePair
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 PkceCodePair
impl RefUnwindSafe for PkceCodePair
impl Send for PkceCodePair
impl Sync for PkceCodePair
impl Unpin for PkceCodePair
impl UnsafeUnpin for PkceCodePair
impl UnwindSafe for PkceCodePair
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