Skip to main content

DomainLinkageValidator

Struct DomainLinkageValidator 

Source
pub struct DomainLinkageValidator<R, V = DefaultVerifier> { /* private fields */ }
Available on crate feature domain-linkage only.
Expand description

Validates domain linkage credentials and DID configuration resources (DID Configuration Resource Verification): the subject is a DID equal to the issuer, iss and sub, the one origin is the requested origin, the credential has an expiration date, no id, no extra claims or header parameters, and its signature verifies under a key of the DID listed under assertionMethod.

A configuration is written by whoever controls the origin, and every entry validated resolves its issuer’s DID, so validate_configuration and validate_linkage validate at most max_credentials entries of one configuration.

§Examples

use identity_kit::domain_linkage::DomainLinkageValidator;
use identity_kit::jose::DefaultVerifier;
use identity_kit::methods::DidKey;
use identity_kit::resolver::Resolver;

let resolver = Resolver::builder().with(DidKey::default()).build();
let validator = DomainLinkageValidator::new(resolver, DefaultVerifier);
assert!(!validator.credential_validator().has_status_check());

Implementations§

Source§

impl<R, V> DomainLinkageValidator<R, V>

Source

pub const DEFAULT_MAX_CREDENTIALS: usize = 32

The most entries of one configuration new validates: 32.

Source§

impl<R: KeyResolver, V: JwsVerifier> DomainLinkageValidator<R, V>

Source

pub fn new(resolver: R, verifier: V) -> Self

A validator resolving keys with resolver and verifying signatures with verifier, validating at most DEFAULT_MAX_CREDENTIALS entries of a configuration.

Source

pub fn from_credential_validator( credentials: JwtCredentialValidator<R, V>, ) -> Self

A validator over credentials, validating at most DEFAULT_MAX_CREDENTIALS entries of a configuration.

Source

pub fn with_max_credentials(self, max_credentials: usize) -> Self

This validator validating at most max_credentials entries of a configuration.

Source

pub fn max_credentials(&self) -> usize

The most entries of one configuration validate_configuration and validate_linkage validate.

Source

pub fn credential_validator(&self) -> &JwtCredentialValidator<R, V>

The credential validator.

Source

pub async fn validate_credential( &self, jwt: &Jwt, origin: &Url, options: &CredentialValidationOptions, ) -> Result<DecodedCredential, DomainLinkageError>

Validates jwt as a domain linkage credential for origin.

§Errors

The first DomainLinkageError found: the format checks first, then the signature, issuer binding and validity period of JwtCredentialValidator::validate.

Source

pub async fn validate_linkage( &self, configuration: &DomainLinkageConfiguration, did: &Did, origin: &Url, options: &CredentialValidationOptions, ) -> Result<DecodedCredential, DomainLinkageError>

Validates the credential of configuration linking did to origin: the first JWT entry issued by did that validates. Entries naming did past the first max_credentials are not validated.

§Errors

DomainLinkageError::NoCredentialFor when no JWT entry names did as issuer, DomainLinkageError::NoValidCredential with the error of each such entry otherwise, DomainLinkageError::TooManyCredentials for those past the limit.

Source

pub async fn validate_configuration( &self, configuration: &DomainLinkageConfiguration, origin: &Url, options: &CredentialValidationOptions, ) -> Result<DomainLinkageReport, DomainLinkageError>

Validates every JWT entry of configuration for origin: succeeds when at least one does, reporting the rest as errors. Entries past the first max_credentials are not validated and report DomainLinkageError::TooManyCredentials.

§Errors

DomainLinkageError::InvalidContext, or DomainLinkageError::NoValidCredential with the error of every JWT entry.

Trait Implementations§

Source§

impl<R: Debug, V: Debug> Debug for DomainLinkageValidator<R, V>

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> 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, 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<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