Skip to main content

TokenTypeIdentifier

Enum TokenTypeIdentifier 

Source
pub enum TokenTypeIdentifier {
    AccessToken,
    RefreshToken,
    IdToken,
    Saml1,
    Saml2,
    Jwt,
}
Available on crate feature token-exchange only.
Expand description

The RFC 8693 section 3 token type identifiers.

The URNs are the wire values, verbatim. This is a closed enum rather than a string because the subject_token_type is a security-relevant statement about how the presented string must be checked, and “a type identifier this server did not recognise” has to be a REFUSAL rather than something that falls through to a default (RFC 8693 section 2.2.2: a subject token that is unacceptable based on policy is an error).

Variants§

§

AccessToken

urn:ietf:params:oauth:token-type:access_token. The only type this server accepts as a subject or actor token, and the only type it issues.

§

RefreshToken

urn:ietf:params:oauth:token-type:refresh_token.

§

IdToken

urn:ietf:params:oauth:token-type:id_token.

§

Saml1

urn:ietf:params:oauth:token-type:saml1.

§

Saml2

urn:ietf:params:oauth:token-type:saml2.

§

Jwt

urn:ietf:params:oauth:token-type:jwt. Note that RFC 8693 section 3 defines this as “any JWT”, which is a statement about ENCODING and not about who issued it; this server does not accept it, because accepting a JWT as a subject token means deciding whose signature to trust, and that is a policy no library can pick on a host’s behalf.

Implementations§

Source§

impl TokenTypeIdentifier

Source

pub fn parse(s: &str) -> Option<Self>

Resolve a wire *_token_type value WITHOUT allocating, returning None for anything RFC 8693 section 3 does not register.

This is the parse the HTTP surface uses, for the reason crate::grant::GrantType::parse exists: FromStr’s error carries the caller’s value, and the router deliberately does not echo it (RFC 6749 s5.2 restricts error_description to a charset an attacker-supplied URN need not respect), so the copy was allocated and dropped unread. The refusal STRING here was already made a &'static str for exactly this rule; the allocation underneath it was missed, and it is the worse one, because the caller chooses its SIZE and this refusal happens before the presented client credential has been checked.

FromStr is unchanged and still carries the value, for the host-side callers that want to report which URN they got wrong.

Source

pub fn as_str(self) -> &'static str

The registered URN, verbatim.

Trait Implementations§

Source§

impl Clone for TokenTypeIdentifier

Source§

fn clone(&self) -> TokenTypeIdentifier

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 Copy for TokenTypeIdentifier

Source§

impl Debug for TokenTypeIdentifier

Source§

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

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

impl<'de> Deserialize<'de> for TokenTypeIdentifier

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for TokenTypeIdentifier

Source§

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

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

impl Eq for TokenTypeIdentifier

Source§

impl FromStr for TokenTypeIdentifier

Source§

type Err = UnknownTokenTypeIdentifier

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for TokenTypeIdentifier

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for TokenTypeIdentifier

Source§

fn eq(&self, other: &TokenTypeIdentifier) -> bool

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

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

Inequality operator !=. Read more
Source§

impl Serialize for TokenTypeIdentifier

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for TokenTypeIdentifier

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.