fido-common: De/serialize credential::public_key::UserEntity::id as bytes

Uses serde_with to serialize and deseriailze the UserEntity::id field as
a byte string instead of a sequence (array) of bytes.
main
Nick Zana 2 years ago
parent 42044f2a46
commit a0bd1c9e01

@ -33,6 +33,7 @@ pub(crate) mod algorithm {
/// > This dictionary is used to supply additional parameters when /// > This dictionary is used to supply additional parameters when
/// > creating a new credential. /// > creating a new credential.
#[cfg_eval]
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Parameters { pub struct Parameters {
@ -79,9 +80,12 @@ pub struct Descriptor {
/// > account to which the new public key credential will be associated at /// > account to which the new public key credential will be associated at
/// > the RP. /// > the RP.
/// Due to deprecation, the `icon` URL is omitted. See <https://github.com/w3c/webauthn/pull/1337/>. /// Due to deprecation, the `icon` URL is omitted. See <https://github.com/w3c/webauthn/pull/1337/>.
#[derive(Debug)] #[cfg_eval]
#[derive(Debug, Clone)]
#[cfg_attr( #[cfg_attr(
feature = "serde", feature = "serde",
serde_as,
skip_serializing_none,
derive(Serialize, Deserialize), derive(Serialize, Deserialize),
serde(rename_all = "camelCase") serde(rename_all = "camelCase")
)] )]
@ -97,6 +101,8 @@ pub struct UserEntity {
// //
// WebAuthn says that "The user handle MUST NOT be empty." To maximimize compatibility, the // WebAuthn says that "The user handle MUST NOT be empty." To maximimize compatibility, the
// definition from the CTAP specs is used. // definition from the CTAP specs is used.
// Bounds: [0, 64] bytes
#[cfg_attr(feature = "serde", serde_as(as = "Bytes"))]
pub id: Vec<u8>, pub id: Vec<u8>,
/// > a human-palatable identifier for a user account. It is intended /// > a human-palatable identifier for a user account. It is intended
/// > only for display, i.e., aiding the user in determining the /// > only for display, i.e., aiding the user in determining the

Loading…
Cancel
Save