[−][src]Struct oxide_auth::code_grant::extensions::Pkce
Proof Key for Code Exchange by OAuth Public Clients
Auth 2.0 public clients utilizing the Authorization Code Grant are susceptible to the authorization code interception attack. This specification describes the attack as well as a technique to mitigate against the threat through the use of Proof Key for Code Exchange (PKCE, pronounced "pixy").
(from the respective RFC 7636)
In short, public clients share a verifier for a secret token when requesting their initial authorization code. When they then make a second request to the autorization server, trading this code for an access token, they can credible assure the server of their identity by presenting the secret token.
The simple plain method only prevents attackers unable to snoop on the connection from
impersonating the client, while the S256 method, which uses one-way hash functions, makes
any attack short of reading the victim client's memory infeasible.
Support for the plain method is OPTIONAL and must be turned on explicitely.
Methods
impl Pkce[src]
pub fn required() -> Pkce[src]
A pkce extensions which requires clients to use it.
pub fn optional() -> Pkce[src]
Pkce extension which will check verifiers if present but not require them.
pub fn allow_plain(&mut self)[src]
Allow usage of the less secure plain verification method. This method is NOT secure
an eavesdropping attacker such as rogue processes capturing a devices requests.
pub fn challenge(
&self,
method: Option<Cow<str>>,
challenge: Option<Cow<str>>
) -> Result<Option<Value>, ()>[src]
&self,
method: Option<Cow<str>>,
challenge: Option<Cow<str>>
) -> Result<Option<Value>, ()>
Create the encoded method for proposed method and challenge.
The method defaults to plain when none is given, effectively offering increased
compatibility but less security. Support for plain is optional and needs to be enabled
explicitely through Pkce::allow_plain. This extension may also require clients to use it,
in which case giving no challenge also leads to an error.
The resulting string MUST NOT be publicly available to the client. Otherwise, it would be trivial for a third party to impersonate the client in the access token request phase. For a SHA256 methods the results would not be quite as severe but still bad practice.
pub fn verify(
&self,
method: Option<Value>,
verifier: Option<Cow<str>>
) -> Result<(), ()>[src]
&self,
method: Option<Value>,
verifier: Option<Cow<str>>
) -> Result<(), ()>
Verify against the encoded challenge.
When the challenge is required, ensure again that a challenge was made and a corresponding method data is present as an extension. This is not strictly necessary since clients should not be able to delete private extension data but this check does not cost a lot.
When a challenge was agreed upon but no verifier is present, this method will return an error.
Trait Implementations
impl AuthorizationAddon for Pkce[src]
fn execute(&self, request: &dyn AuthorizationRequest) -> AddonResult[src]
impl AccessTokenAddon for Pkce[src]
fn execute(
&self,
request: &dyn AccessTokenRequest,
data: Option<Value>
) -> AddonResult[src]
&self,
request: &dyn AccessTokenRequest,
data: Option<Value>
) -> AddonResult
impl GrantExtension for Pkce[src]
fn identifier(&self) -> &'static str[src]
Auto Trait Implementations
impl Unpin for Pkce
impl Send for Pkce
impl Sync for Pkce
impl RefUnwindSafe for Pkce
impl UnwindSafe for Pkce
Blanket Implementations
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Erased for T
impl<T> Typeable for T where
T: Any,
T: Any,
impl<T> UnsafeAny for T where
T: Any,
T: Any,
impl<T> IntoCollection<T> for T
fn into_collection<A>(self) -> SmallVec<A> where
A: Array<Item = T>,
A: Array<Item = T>,
fn mapped<U, F, A>(self, f: F) -> SmallVec<A> where
A: Array<Item = U>,
F: FnMut(T) -> U,
A: Array<Item = U>,
F: FnMut(T) -> U,
impl<T, I> AsResult<T, I> for T where
I: Input,
I: Input,