pub trait AuthScheme:
Send
+ Sync
+ Debug {
// Required methods
fn scheme_id(&self) -> AuthSchemeId;
fn identity_resolver(
&self,
identity_resolvers: &dyn GetIdentityResolver,
) -> Option<SharedIdentityResolver>;
fn signer(&self) -> &dyn Sign;
}
Expand description
An auth scheme.
Auth schemes have unique identifiers (the scheme_id
),
and provide an identity resolver and a signer.
Required Methods§
Sourcefn scheme_id(&self) -> AuthSchemeId
fn scheme_id(&self) -> AuthSchemeId
Returns the unique identifier associated with this auth scheme.
This identifier is used to refer to this auth scheme from the
ResolveAuthSchemeOptions
, and is also associated with
identity resolvers in the config.
Sourcefn identity_resolver(
&self,
identity_resolvers: &dyn GetIdentityResolver,
) -> Option<SharedIdentityResolver>
fn identity_resolver( &self, identity_resolvers: &dyn GetIdentityResolver, ) -> Option<SharedIdentityResolver>
Returns the identity resolver that can resolve an identity for this scheme, if one is available.
The AuthScheme
doesn’t actually own an identity resolver. Rather, identity resolvers
are configured as runtime components. The auth scheme merely chooses a compatible identity
resolver from the runtime components via the GetIdentityResolver
trait. The trait is
given rather than the full set of runtime components to prevent complex resolution logic
involving multiple components from taking place in this function, since that’s not the
intended use of this design.