Skip to main content

Module chain

Module chain 

Expand description

The first-success provider chain (ADR 0021 §5, cratestack#1243): several AuthProviders composed into one, in order.

let auth = first_success(oauth).or(device_signature).or(cose_signer);

For each member, in order:

  1. If its credential is Credential::Absent, it is skipped without being called.
  2. If it returns an authenticated context, that is the answer.
  3. If it returns an error (an AuthRefusal or any other), that is the answer. A credential one member refuses is never rescued by another: the chain fails closed.
  4. If it returns an anonymous context, the next member is asked.

When no member authenticates, the chain answers with the first anonymous context a member returned (so what a provider put in it, such as its extensions, is kept), or a plain anonymous context when every member was skipped, and the schema’s policies decide. A request that carries two credentials is resolved by order: the first member that authenticates it wins.

The chain is generic and static (Or<Or<A, B>, C>): AuthProvider returns impl Future and is not object-safe, so there is no dyn list.

Structs§

FirstSuccess
A first-success chain of AuthProviders, itself an AuthProvider. Built with first_success.
Or
Two chain members, first asked before next.

Functions§

first_success
Starts a first-success chain with first; add members with FirstSuccess::or. See the module documentation.