webauthn_authenticator_rs/ctap2/
yubikey.rs

1use async_trait::async_trait;
2
3use crate::{
4    prelude::WebauthnCError,
5    transport::{
6        yubikey::{YubiKeyConfig, YubiKeyToken},
7        Token,
8    },
9    ui::UiCallback,
10};
11
12use super::Ctap20Authenticator;
13
14/// YubiKey vendor-specific commands.
15///
16/// ## Warning
17///
18/// These commands currently operate on *any* [`Ctap20Authenticator`][], and do
19/// not filter to just YubiKey devices. Due to the nature of CTAP
20/// vendor-specific commands, this may cause unexpected or undesirable behaviour
21/// on other vendors' keys.
22///
23/// Protocol notes are in [`crate::transport::yubikey`].
24#[async_trait]
25pub trait YubiKeyAuthenticator {
26    async fn get_yubikey_config(&mut self) -> Result<YubiKeyConfig, WebauthnCError>;
27}
28
29#[async_trait]
30impl<'a, T: Token + YubiKeyToken, U: UiCallback> YubiKeyAuthenticator
31    for Ctap20Authenticator<'a, T, U>
32{
33    #[inline]
34    async fn get_yubikey_config(&mut self) -> Result<YubiKeyConfig, WebauthnCError> {
35        self.token.get_yubikey_config().await
36    }
37}