pub struct NonDiscoverableAuthenticationClientState<'rp_id, 'prf_first, 'prf_second>(/* private fields */);Expand description
Container of a NonDiscoverableCredentialRequestOptions that has been used to start the authentication
ceremony. This gets sent to the client ASAP.
Implementations§
Source§impl<'rp_id, 'prf_first, 'prf_second> NonDiscoverableAuthenticationClientState<'rp_id, 'prf_first, 'prf_second>
impl<'rp_id, 'prf_first, 'prf_second> NonDiscoverableAuthenticationClientState<'rp_id, 'prf_first, 'prf_second>
Sourcepub const fn options(
&self,
) -> &NonDiscoverableCredentialRequestOptions<'rp_id, 'prf_first, 'prf_second>
pub const fn options( &self, ) -> &NonDiscoverableCredentialRequestOptions<'rp_id, 'prf_first, 'prf_second>
Returns the NonDiscoverableCredentialRequestOptions that was used to start an authentication ceremony.
Trait Implementations§
Source§impl<'rp_id, 'prf_first, 'prf_second> Debug for NonDiscoverableAuthenticationClientState<'rp_id, 'prf_first, 'prf_second>
impl<'rp_id, 'prf_first, 'prf_second> Debug for NonDiscoverableAuthenticationClientState<'rp_id, 'prf_first, 'prf_second>
Source§impl Serialize for NonDiscoverableAuthenticationClientState<'_, '_, '_>
Available on crate feature serde only.
impl Serialize for NonDiscoverableAuthenticationClientState<'_, '_, '_>
Available on crate feature
serde only.Source§fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where
S: Serializer,
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where
S: Serializer,
Serializes self according to NonDiscoverableCredentialRequestOptions::serialize.
§Examples
/// Retrieves the `AuthTransports` associated with the unique `cred_id`
/// from the database.
fn get_transports(cred_id: CredentialId<&[u8]>) -> Result<AuthTransports, DecodeAuthTransportsErr> {
// ⋮
}
let mut creds = AllowedCredentials::with_capacity(1);
// `CredentialId::try_from` only exists when `custom` is enabled; and even then, it is
// likely never needed since the `CredentialId` was originally sent from the client and is likely
// stored in a database which would be fetched by `UserHandle` or `Authentication::raw_id`.
let id = CredentialId::try_from(vec![0; 16].into_boxed_slice())?;
let transports = get_transports((&id).into())?;
creds.push(AllowedCredential {
credential: PublicKeyCredentialDescriptor { id, transports },
extension: CredentialSpecificExtension {
prf: Some(PrfInputOwned {
first: vec![2; 6],
second: Some(vec![3; 2]),
ext_req: ExtensionReq::Require,
}),
},
});
let rp_id = RpId::Domain(AsciiDomain::try_from("example.com".to_owned())?);
let mut options = NonDiscoverableCredentialRequestOptions::second_factor(&rp_id, creds);
let opts = &mut options.options;
opts.hints = Hints::EMPTY.add(PublicKeyCredentialHint::SecurityKey);
// This is actually useless since `CredentialSpecificExtension` takes priority
// when the client receives the payload. We set it for illustration purposes only.
// If `creds` contained an `AllowedCredential` that didn't set
// `CredentialSpecificExtension::prf`, then this would be used for it.
opts.extensions = Extension {
prf: Some((PrfInput {
first: [0; 4].as_slice(),
second: None,
}, ExtensionReq::Require)),
};
// Since we are requesting the PRF extension, we must require user verification; otherwise
// `NonDiscoverableCredentialRequestOptions::start_ceremony` would error.
opts.user_verification = UserVerificationRequirement::Required;
let client_state = serde_json::to_string(&options.start_ceremony()?.1).unwrap();
let json = serde_json::json!({
"mediation":"required",
"publicKey":{
"challenge":"AAAAAAAAAAAAAAAAAAAAAA",
"timeout":300000,
"rpId":"example.com",
"allowCredentials":[
{
"type":"public-key",
"id":"AAAAAAAAAAAAAAAAAAAAAA",
"transports":["usb"]
}
],
"userVerification":"required",
"hints":[
"security-key"
],
"extensions":{
"prf":{
"eval":{
"first":"AAAAAA"
},
"evalByCredential":{
"AAAAAAAAAAAAAAAAAAAAAA":{
"first":"AgICAgIC",
"second":"AwM"
}
}
}
}
}
}).to_string();
// Since `Challenge`s are randomly generated, we don't know what it will be; thus
// we test the JSON string for everything except it.
assert_eq!(client_state.get(..50), json.get(..50));
assert_eq!(client_state.get(72..), json.get(72..));Auto Trait Implementations§
impl<'rp_id, 'prf_first, 'prf_second> Freeze for NonDiscoverableAuthenticationClientState<'rp_id, 'prf_first, 'prf_second>
impl<'rp_id, 'prf_first, 'prf_second> RefUnwindSafe for NonDiscoverableAuthenticationClientState<'rp_id, 'prf_first, 'prf_second>
impl<'rp_id, 'prf_first, 'prf_second> Send for NonDiscoverableAuthenticationClientState<'rp_id, 'prf_first, 'prf_second>
impl<'rp_id, 'prf_first, 'prf_second> Sync for NonDiscoverableAuthenticationClientState<'rp_id, 'prf_first, 'prf_second>
impl<'rp_id, 'prf_first, 'prf_second> Unpin for NonDiscoverableAuthenticationClientState<'rp_id, 'prf_first, 'prf_second>
impl<'rp_id, 'prf_first, 'prf_second> UnsafeUnpin for NonDiscoverableAuthenticationClientState<'rp_id, 'prf_first, 'prf_second>
impl<'rp_id, 'prf_first, 'prf_second> UnwindSafe for NonDiscoverableAuthenticationClientState<'rp_id, 'prf_first, 'prf_second>
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
Mutably borrows from an owned value. Read more