Skip to main content

AuthplaneResource

Struct AuthplaneResource 

Source
pub struct AuthplaneResource { /* private fields */ }

Implementations§

Source§

impl AuthplaneResource

Source

pub async fn create( issuer: &str, resource: &str, scopes: &[String], fetch_settings: FetchSettings, ) -> Result<Self, VerifierError>

Source

pub async fn create_with_options( issuer: &str, resource: &str, scopes: &[String], fetch_settings: FetchSettings, options: ResourceOptions, ) -> Result<Self, VerifierError>

Source

pub fn resource(&self) -> &str

Source

pub fn issuer(&self) -> &str

Source

pub fn scopes(&self) -> &[String]

Source

pub fn prm_response(&self) -> ProtectedResourceMetadata

Source

pub fn prm_document_url(&self) -> Result<String, AuthplaneError>

RFC 9728 §3.1 — absolute URL of this resource’s metadata document, derived from the resource identifier. This is where a server that hosts its own document should serve it.

Source

pub fn resource_metadata_url(&self) -> &str

The URL advertised as the RFC 9728 §5.1 resource_metadata parameter of every WWW-Authenticate challenge this resource emits: the ResourceOptions::with_resource_metadata_url override when set, otherwise Self::prm_document_url.

Source

pub fn www_authenticate(&self, error: &VerifierError, realm: &str) -> String

Build the WWW-Authenticate challenge for a verifier failure on this resource: www_authenticate() plus the RFC 9728 §5.1 resource_metadata parameter carrying Self::resource_metadata_url. Adapters should prefer this over the free function so every 401 tells the client where to discover the authorization server. realm is optional; pass "" to omit it.

Source

pub async fn verify(&self, token: &str) -> Result<VerifiedClaims, VerifierError>

Verify a bearer access token (RFC 6750 §2.1).

Rejects a DPoP-bound token rather than accepting it as a bearer one. A cnf claim means the authorization server issued this token sender-constrained, and the binding is the whole reason a stolen token is useless to a thief. This entrypoint has no request context, so it has no proof to check against — accepting the token anyway would silently discard the constraint, which is a downgrade, not a limitation.

Mode dispatch comes first, so a malformed cnf cannot select a weaker path than a well-formed one. It is not separated out beyond that: verify_with_context checks for cnf.jkt before the proof-missing check and answers VerifierError::InvalidClaims for a cnf without one, which this entrypoint does not reproduce — there is no proof to bind either way here, so the malformed case folds into the same rejection. Both reject; the class differs, and the catalog case that pins invalid_claims for that shape (rfc9449-dpop-bound-token-must-contain-cnf-jkt) is specified against the DPoP entrypoint with a proof present, not against this one.

Source

pub async fn verify_with_context( &self, token: &str, context: &DpopRequestContext, ) -> Result<VerifiedClaims, VerifierError>

RFC 9449 §7 — unified verify entrypoint.

Accepts both bearer and DPoP-bound access tokens behind a single API that takes a request-level DpopRequestContext and uses the token’s cnf.jkt claim to decide whether sender-constraint validation must run, so a caller need not decide up front which entrypoint a token requires.

Behavior matrix:

  • Token without cnf/cnf.jkt: ignored request context; verification succeeds as a bearer token.
  • Token with cnf but no cnf.jkt: rejected with VerifierError::InvalidClaims — structurally malformed confirmation claim.
  • Token with cnf.jkt and context.proof == None: rejected with VerifierError::DpopProofMissing.
  • Token with cnf.jkt and context.proof = Some(_): proof is validated (method, URL, nonce, ath, and cnf.jkt ↔ jwk thumbprint binding). Mismatch surfaces as VerifierError::InvalidClaims.

Trait Implementations§

Source§

impl Clone for AuthplaneResource

Source§

fn clone(&self) -> Self

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 Debug for AuthplaneResource

Source§

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

Formats the value using the given formatter. Read more

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more