Rust

oauth2

Module

Request values an OAuth2 / OpenID Connect authorization server parses and checks: prompts, redirect URIs, resource indicators, authorization details, pushed authorization requests and client metadata documents.

Contents

7 submodules, and what the module defines itself.

use utopia_auth::oauth2::AuthorizationDetail;
Rust
pub enum AuthorizationDetail

A common field of an authorization_details entry (RFC 9396).

use utopia_auth::oauth2::Prompt;
Rust
pub enum Prompt

A value of the OpenID Connect prompt request parameter.

oauth2::authorization_details

Own page

Rich authorization requests: the authorization_details parameter (RFC 9396).

use utopia_auth::oauth2::authorization_details::AuthorizationDetails;
Rust
pub struct AuthorizationDetails(Vec<Array>)

The authorization_details of a request (RFC 9396): the object entries of a list. Anything malformed contributes nothing.

oauth2::client_id_metadata_document

Own page

Client ID Metadata Documents: the metadata an OAuth2 client publishes at its client identifier URL.

use utopia_auth::oauth2::client_id_metadata_document::ClientIdMetadataDocument;
Rust
pub struct ClientIdMetadataDocument

A validated OAuth Client ID Metadata Document. Unknown metadata is kept.

oauth2::client_identifier_url

Own page

Client identifier URLs: OAuth2 clients identified by the URL of their metadata document.

use utopia_auth::oauth2::client_identifier_url::ClientIdentifierUrl;
Rust
pub struct ClientIdentifierUrl

A client identifier URL, from the OAuth Client ID Metadata Document draft.

It is kept verbatim: client ids compare as plain strings.

oauth2::par

Own page

Pushed authorization request URIs (RFC 9126).

use utopia_auth::oauth2::par::Par;
Rust
pub struct Par

A pushed authorization request request_uri (RFC 9126): a deployment prefix plus a stored request id.

Rust
use utopia_auth::oauth2::Par;

let prefix = b"urn:ietf:params:oauth:request_uri:";
let par = Par::from_id(prefix, b"abc123")?;
assert_eq!(par.request_uri(), b"urn:ietf:params:oauth:request_uri:abc123");
assert_eq!(Par::from_request_uri(prefix, &par.request_uri())?.id(), b"abc123");

oauth2::prompts

Own page

The parsed OpenID Connect prompt request parameter.

use utopia_auth::oauth2::prompts::Prompts;
Rust
pub struct Prompts(Vec<Prompt>)

The parsed OpenID Connect prompt parameter: distinct values in first-seen order, where none stands alone.

Rust
use utopia_auth::oauth2::{Prompt, Prompts};

let prompts = Prompts::from_string(b"login consent login")?;
assert_eq!(prompts.to_vec(), ["login", "consent"]);
assert!(prompts.contains(Prompt::Consent));
assert!(Prompts::from_string(b"none login").is_err());

oauth2::redirect_uris

Own page

A client's registered redirect URIs and how a presented one matches.

use utopia_auth::oauth2::redirect_uris::RedirectUris;
Rust
pub struct RedirectUris(Vec<Vec<u8>>)

A client's registered redirect URIs: exact matching, plus any port on http loopback URIs when asked for (RFC 8252 §7.3, public clients only).

Rust
use utopia_auth::oauth2::RedirectUris;

let uris = RedirectUris::from_strings([&b"https://app.example/callback"[..], b"http://127.0.0.1/cb"]);
assert!(uris.matches(b"https://app.example/callback", false));
assert!(!uris.matches(b"https://app.example/other", false));
// Loopback redirects may use any port, when allowed.
assert!(uris.matches(b"http://127.0.0.1:51004/cb", true));

oauth2::resource_indicators

Own page

Resource indicators: the resource request parameter (RFC 8707).

use utopia_auth::oauth2::resource_indicators::ResourceIndicators;
Rust
pub struct ResourceIndicators(Vec<Vec<u8>>)

The resource indicators of a request (RFC 8707): distinct absolute http(s) URIs without fragments.

use utopia_auth::oauth2::resource_indicators::Resources;
Rust
pub enum Resources<'a>

The resource request parameter: absent, one value, or several.