pub struct Pkce {
pub verifier: String,
pub challenge: String,
}Expand description
A PKCE pair (RFC 7636, S256): keep the verifier in the session, send the challenge.
PKCE ties the code the provider returns to the browser session that started the sign-in, so a stolen code is useless.
§Examples
use ocre::oauth::Pkce;
let pkce = Pkce::new();
assert_eq!(pkce.verifier.len(), 43);
assert_eq!(Pkce::challenge_for(&pkce.verifier), pkce.challenge);Fields§
§verifier: StringThe secret, sent with the token request (exchange_code).
challenge: StringBASE64URL(SHA-256(verifier)), sent in the authorization URL.
Implementations§
Source§impl Pkce
impl Pkce
Sourcepub fn new() -> Self
pub fn new() -> Self
A new random verifier (32 bytes) and its challenge.
§Examples
assert_ne!(ocre::oauth::Pkce::new(), ocre::oauth::Pkce::new());Sourcepub fn challenge_for(verifier: &str) -> String
pub fn challenge_for(verifier: &str) -> String
The S256 challenge of verifier.
§Examples
// The example of RFC 7636, appendix B.
let challenge = ocre::oauth::Pkce::challenge_for("dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk");
assert_eq!(challenge, "E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM");Trait Implementations§
impl Eq for Pkce
impl StructuralPartialEq for Pkce
Auto Trait Implementations§
impl Freeze for Pkce
impl RefUnwindSafe for Pkce
impl Send for Pkce
impl Sync for Pkce
impl Unpin for Pkce
impl UnsafeUnpin for Pkce
impl UnwindSafe for Pkce
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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
Checks if this value is equivalent to the given key. Read more
§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
Compare self to
key and return true if they are equal.