pub struct CoseAuthProvider<A> { /* private fields */ }Expand description
Wraps an AuthProvider and authenticates a COSE-verified signer through
a service key registry and, once switched on, the device key registry.
Each registry must be the one the envelope verifies with, or stricter, so
revoking a key there revokes it here. But with_service_keys must hold
service keys only (see “Security”): do not pass it a resolver that also
holds device keys.
The service registry is asked before the device registry, and the device
registry only after authenticate_devices.
// Services only (the default): a device key is anonymous.
let provider = CoseAuthProvider::new(header_provider, device_registry)
.with_service_keys(service_registry);
// Also devices, where device enrolment is gated.
let provider = provider.authenticate_devices(true);§Security
A device key proves a device, not a user, so device authentication is off by
default and a device signer is anonymous. With
authenticate_devices(true), any request
sealed by an enrolled device key is authenticated, with no user (no
id_jwt), on every method, regardless of the inner provider’s
TransportCallerMode. auth() != null then means “holds an enrolled device
or service key”, and revoking the key, not token expiry, is what bounds
access. Turn it on only where device enrolment itself is gated. A service
key authenticates either way. See the module docs.
with_service_keys must hold service keys only; a device key placed there
authenticates as a service whatever the gate. The service registry is asked
first and authenticates regardless of authenticate_devices, so passing it
the resolver devices enrol into (for example the same
RegistryVerifierResolver the envelope verifies with) makes every enrolled
device a kind: service caller with the gate off.
An ESP256 or WebCrypto device key can authenticate only through the
service registry (not behind the device gate), because DeviceKeyResolver
is Ed25519-only.
The id is cose:<thumbprint> only with the default ThumbprintPrincipal
prefix. The context also carries kind, thumbprint and alg.
Implementations§
Source§impl<A> CoseAuthProvider<A>
impl<A> CoseAuthProvider<A>
Sourcepub fn new(inner: A, devices: Arc<dyn DeviceKeyResolver>) -> CoseAuthProvider<A>
pub fn new(inner: A, devices: Arc<dyn DeviceKeyResolver>) -> CoseAuthProvider<A>
Wrap inner. devices, a [DeviceKeyResolver] (its thumbprint lookup
is the one used), is consulted only after
authenticate_devices(true).
Sourcepub fn authenticate_devices(self, enabled: bool) -> CoseAuthProvider<A>
pub fn authenticate_devices(self, enabled: bool) -> CoseAuthProvider<A>
Switch device authentication on or off (off by default).
Off, a verified device signer is anonymous: the device registry is not
asked and policy refuses it (a failing service registry, asked first,
still errors with 500). On, a
device key the registry still holds authenticates as kind device
(see the type docs, “Security”: this makes the key alone a caller).
Service keys (with_service_keys) are not
affected.
Sourcepub fn with_service_keys(
self,
services: Arc<dyn CoseVerifierResolver>,
) -> CoseAuthProvider<A>
pub fn with_service_keys( self, services: Arc<dyn CoseVerifierResolver>, ) -> CoseAuthProvider<A>
Also authenticate verified service keys, which services holds under
any algorithm it verifies (for example a RegistryVerifierResolver).
services must hold service keys only: a device key here authenticates
as a service whatever the gate.
Trait Implementations§
Source§impl<A> AuthProvider for CoseAuthProvider<A>where
A: AuthProvider,
impl<A> AuthProvider for CoseAuthProvider<A>where
A: AuthProvider,
type Error = CratestackError
async fn authenticate( &self, request: &RequestContext<'_>, ) -> Result<CratestackContext, CratestackError>
Source§fn credential<'r>(&self, request: &RequestContext<'r>) -> Credential<'r>
fn credential<'r>(&self, request: &RequestContext<'r>) -> Credential<'r>
request carries this provider’s credential, read from the
request head without authenticating (the body may be empty). The
first-success chain skips a provider that
answers [Credential::Absent]. The default,
[Credential::Unknown], means the provider is always called, as
before this method existed. See [Credential].Source§impl<A> Clone for CoseAuthProvider<A>where
A: Clone,
impl<A> Clone for CoseAuthProvider<A>where
A: Clone,
Source§fn clone(&self) -> CoseAuthProvider<A>
fn clone(&self) -> CoseAuthProvider<A>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<A> !RefUnwindSafe for CoseAuthProvider<A>
impl<A> !UnwindSafe for CoseAuthProvider<A>
impl<A> Freeze for CoseAuthProvider<A>where
A: Freeze,
impl<A> Send for CoseAuthProvider<A>where
A: Send,
impl<A> Sync for CoseAuthProvider<A>where
A: Sync,
impl<A> Unpin for CoseAuthProvider<A>where
A: Unpin,
impl<A> UnsafeUnpin for CoseAuthProvider<A>where
A: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<T> MaybeSend for T
impl<T> MaybeSendSync for T
impl<T> OrderedSeq<'_, T> for Twhere
T: Clone,
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
§type Iter<'a> = Once<&'a T>
where
T: 'a
type Iter<'a> = Once<&'a T> where T: 'a
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
§fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
MaybeRef].