Skip to main content

AuthorizationRequest

Struct AuthorizationRequest 

Source
#[non_exhaustive]
pub struct AuthorizationRequest<'a> { pub response_type: Option<Cow<'a, str>>, pub client_id: Option<Cow<'a, str>>, pub redirect_uri: Option<Cow<'a, str>>, pub scope: Option<Cow<'a, str>>, pub state: Option<Cow<'a, str>>, pub code_challenge: Option<Cow<'a, str>>, pub code_challenge_method: Option<Cow<'a, str>>, pub resource: Vec<Cow<'a, str>>, pub authorization_details: Option<Cow<'a, str>>, pub acr_values: Option<Cow<'a, str>>, pub max_age: Option<Cow<'a, str>>, }
Expand description

The raw authorization request as it arrives on the wire (RFC 6749 section 4.1.1 plus the RFC 7636 PKCE parameters). The host parses its query string into this; every member is optional because every member can be absent in a real (invalid) request. #[non_exhaustive]: rar adds authorization_details and consent adds two more, and the doc above explains why they live here rather than being read off the query separately, which means this type is where every future authorization parameter lands as well.

AuthorizationRequest::from_pairs is the path a host actually wants: it takes the decoded query pairs and applies the section 3.1 rules about unknown and repeated parameters, which a struct literal assembled by hand does not. For a request built in code rather than parsed, start from Default::default() and assign; every field is public and every field is legitimately absent, so there is nothing a literal could express that this cannot.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§response_type: Option<Cow<'a, str>>

Must be code.

§client_id: Option<Cow<'a, str>>

The requesting client.

§redirect_uri: Option<Cow<'a, str>>

Requested redirect target; must exact-match a registered URI when present.

§scope: Option<Cow<'a, str>>

Requested scope, space delimited; absent means the client’s registered default.

§state: Option<Cow<'a, str>>

Opaque client state, echoed back verbatim.

§code_challenge: Option<Cow<'a, str>>

The PKCE challenge (REQUIRED in OAuth 2.1 for the authorization code grant).

§code_challenge_method: Option<Cow<'a, str>>

The PKCE method; only S256.

§resource: Vec<Cow<'a, str>>

RFC 8707 resource indicators: the resource server(s) the client intends the issued token to be used at.

A Vec rather than an Option<Cow> because RFC 8707 section 2 says the parameter MAY be repeated, and a client naming two resource servers means both, not the last one. An empty Vec allocates nothing, so a request that carries no resource still costs what it did before this parameter existed.

§authorization_details: Option<Cow<'a, str>>

RFC 9396 section 2 authorization_details: a JSON array of objects, each naming a type that defines the rest of it.

RAW TEXT, not a parsed structure, for the reason the rest of this type is raw text: a server cannot reject what it cannot represent, and this parameter’s failure modes (unparseable, oversized, an unknown type) all have to reach the state machine so it can answer them the way RFC 9396 section 5 prescribes. Parsing happens in crate::rar::AuthorizationDetails::parse, under this crate’s bounds, and only the validated form carries the result.

NOT FEATURE GATED, which is the same decision crate::ErrorCode::InvalidAuthorizationDetails records for the error code and taken for the same reason. Without rar this crate supports no authorization detail type at all, so RFC 9396 section 5’s condition is met by EVERY request that carries the parameter and every one of them has to be refused. A field that disappeared with the feature left the parameter nowhere to land, and a parameter that lands nowhere is a parameter accepted and ignored, which is the one outcome section 5 forbids. So the field exists in every build; what changes with the feature is whether the value is honoured or refused, and that is decided during validation, not during parsing.

§acr_values: Option<Cow<'a, str>>
Available on crate feature consent only.

RFC 9470 section 4 / OpenID Connect Core section 3.1.2.1 acr_values: the authentication context classes the client will accept, space delimited, in order of preference.

ON THIS TYPE rather than parsed straight off the query, and that is the whole of the fix for a real gap. Every way into the authorization endpoint (a plain query, an RFC 9126 pushed request, an RFC 9101 signed request object) funnels through this struct, so a parameter that lives here is a parameter every path must carry; a parameter parsed separately from the query is a parameter the other two paths silently drop. That is exactly what happened to these two: PAR and JAR requests disabled step-up entirely, and for JAR the server was reading intermediary-rewritable query text on a request whose only purpose is that it cannot be rewritten (RFC 9101 section 6.3).

RAW TEXT for the same reason as the rest of this type, and parsed into crate::consent::AuthenticationRequirement by validation.

§max_age: Option<Cow<'a, str>>
Available on crate feature consent only.

RFC 9470 section 4 / OpenID Connect Core section 3.1.2.1 max_age: how old the user’s authentication may be, in seconds. See AuthorizationRequest::acr_values for why it is a field here rather than something read off the query.

Implementations§

Source§

impl<'a> AuthorizationRequest<'a>

Source

pub fn from_pairs<I, K, V>(pairs: I) -> Self
where I: IntoIterator<Item = (K, V)>, K: AsRef<str>, V: Into<Cow<'a, str>>,

Collect a request from already-decoded (name, value) query pairs.

Unknown parameters are ignored, which RFC 6749 section 3.1 requires. A repeated parameter keeps the FIRST occurrence: section 3.1 says a parameter MUST NOT appear more than once, and last-wins is the smuggling-friendly choice when two intermediaries disagree about which copy counts.

Trait Implementations§

Source§

impl<'a> Clone for AuthorizationRequest<'a>

Source§

fn clone(&self) -> AuthorizationRequest<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for AuthorizationRequest<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Default for AuthorizationRequest<'a>

Source§

fn default() -> AuthorizationRequest<'a>

Returns the “default value” for a type. Read more
Source§

impl<'a> Eq for AuthorizationRequest<'a>

Source§

impl<'a> PartialEq for AuthorizationRequest<'a>

Source§

fn eq(&self, other: &AuthorizationRequest<'a>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for AuthorizationRequest<'a>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.