Skip to content

Commit 5d20800

Browse files
committed
Rename User to PublicKeyCredentialUserEntity
1 parent f96f753 commit 5d20800

File tree

9 files changed

+51
-47
lines changed

9 files changed

+51
-47
lines changed

examples/ctap2.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ use authenticator::{
77
crypto::COSEAlgorithm,
88
ctap2::server::{
99
AuthenticationExtensionsClientInputs, CredentialProtectionPolicy,
10-
PublicKeyCredentialDescriptor, PublicKeyCredentialParameters, RelyingParty,
11-
ResidentKeyRequirement, Transport, User, UserVerificationRequirement,
10+
PublicKeyCredentialDescriptor, PublicKeyCredentialParameters,
11+
PublicKeyCredentialUserEntity, RelyingParty, ResidentKeyRequirement, Transport,
12+
UserVerificationRequirement,
1213
},
1314
statecallback::StateCallback,
1415
Pin, StatusPinUv, StatusUpdate,
@@ -139,7 +140,7 @@ fn main() {
139140
}
140141
});
141142

142-
let user = User {
143+
let user = PublicKeyCredentialUserEntity {
143144
id: "user_id".as_bytes().to_vec(),
144145
name: Some("A. User".to_string()),
145146
display_name: None,

examples/ctap2_discoverable_creds.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use authenticator::{
77
crypto::COSEAlgorithm,
88
ctap2::server::{
99
AuthenticationExtensionsClientInputs, PublicKeyCredentialDescriptor,
10-
PublicKeyCredentialParameters, RelyingParty, ResidentKeyRequirement, Transport, User,
11-
UserVerificationRequirement,
10+
PublicKeyCredentialParameters, PublicKeyCredentialUserEntity, RelyingParty,
11+
ResidentKeyRequirement, Transport, UserVerificationRequirement,
1212
},
1313
statecallback::StateCallback,
1414
Pin, StatusPinUv, StatusUpdate,
@@ -105,7 +105,7 @@ fn register_user(manager: &mut AuthenticatorService, username: &str, timeout_ms:
105105
}
106106
});
107107

108-
let user = User {
108+
let user = PublicKeyCredentialUserEntity {
109109
id: username.as_bytes().to_vec(),
110110
name: Some(username.to_string()),
111111
display_name: None,

examples/test_exclude_list.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ use authenticator::{
77
crypto::COSEAlgorithm,
88
ctap2::commands::StatusCode,
99
ctap2::server::{
10-
PublicKeyCredentialDescriptor, PublicKeyCredentialParameters, RelyingParty,
11-
ResidentKeyRequirement, Transport, User, UserVerificationRequirement,
10+
PublicKeyCredentialDescriptor, PublicKeyCredentialParameters,
11+
PublicKeyCredentialUserEntity, RelyingParty, ResidentKeyRequirement, Transport,
12+
UserVerificationRequirement,
1213
},
1314
errors::{AuthenticatorError, CommandError, HIDError, UnsupportedOption},
1415
statecallback::StateCallback,
@@ -134,7 +135,7 @@ fn main() {
134135
}
135136
});
136137

137-
let user = User {
138+
let user = PublicKeyCredentialUserEntity {
138139
id: "user_id".as_bytes().to_vec(),
139140
name: Some("A. User".to_string()),
140141
display_name: None,

src/authenticatorservice.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
use crate::ctap2::commands::client_pin::Pin;
66
use crate::ctap2::server::{
77
AuthenticationExtensionsClientInputs, PublicKeyCredentialDescriptor,
8-
PublicKeyCredentialParameters, RelyingParty, ResidentKeyRequirement, User,
9-
UserVerificationRequirement,
8+
PublicKeyCredentialParameters, PublicKeyCredentialUserEntity, RelyingParty,
9+
ResidentKeyRequirement, UserVerificationRequirement,
1010
};
1111
use crate::errors::*;
1212
use crate::manager::Manager;
@@ -18,7 +18,7 @@ pub struct RegisterArgs {
1818
pub client_data_hash: [u8; 32],
1919
pub relying_party: RelyingParty,
2020
pub origin: String,
21-
pub user: User,
21+
pub user: PublicKeyCredentialUserEntity,
2222
pub pub_cred_params: Vec<PublicKeyCredentialParameters>,
2323
pub exclude_list: Vec<PublicKeyCredentialDescriptor>,
2424
pub user_verification_req: UserVerificationRequirement,
@@ -318,7 +318,8 @@ mod tests {
318318
use super::{AuthenticatorService, AuthenticatorTransport, Pin, RegisterArgs, SignArgs};
319319
use crate::consts::PARAMETER_SIZE;
320320
use crate::ctap2::server::{
321-
RelyingParty, ResidentKeyRequirement, User, UserVerificationRequirement,
321+
PublicKeyCredentialUserEntity, RelyingParty, ResidentKeyRequirement,
322+
UserVerificationRequirement,
322323
};
323324
use crate::errors::AuthenticatorError;
324325
use crate::statecallback::StateCallback;
@@ -439,7 +440,7 @@ mod tests {
439440
name: None,
440441
},
441442
origin: "example.com".to_string(),
442-
user: User {
443+
user: PublicKeyCredentialUserEntity {
443444
id: "user_id".as_bytes().to_vec(),
444445
name: Some("A. User".to_string()),
445446
display_name: None,
@@ -515,7 +516,7 @@ mod tests {
515516
name: None,
516517
},
517518
origin: "example.com".to_string(),
518-
user: User {
519+
user: PublicKeyCredentialUserEntity {
519520
id: "user_id".as_bytes().to_vec(),
520521
name: Some("A. User".to_string()),
521522
display_name: None,
@@ -610,7 +611,7 @@ mod tests {
610611
name: None,
611612
},
612613
origin: "example.com".to_string(),
613-
user: User {
614+
user: PublicKeyCredentialUserEntity {
614615
id: "user_id".as_bytes().to_vec(),
615616
name: Some("A. User".to_string()),
616617
display_name: None,

src/ctap2/commands/credential_management.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ use super::{Command, CommandError, PinUvAuthCommand, RequestCtap2, StatusCode};
22
use crate::{
33
crypto::{COSEKey, PinUvAuthParam, PinUvAuthToken},
44
ctap2::server::{
5-
PublicKeyCredentialDescriptor, RelyingParty, RpIdHash, User, UserVerificationRequirement,
5+
PublicKeyCredentialDescriptor, PublicKeyCredentialUserEntity, RelyingParty, RpIdHash,
6+
UserVerificationRequirement,
67
},
78
errors::AuthenticatorError,
89
transport::errors::HIDError,
@@ -21,7 +22,7 @@ use std::fmt;
2122
struct CredManagementParams {
2223
rp_id_hash: Option<RpIdHash>, // RP ID SHA-256 hash
2324
credential_id: Option<PublicKeyCredentialDescriptor>, // Credential Identifier
24-
user: Option<User>, // User Entity
25+
user: Option<PublicKeyCredentialUserEntity>, // User Entity
2526
}
2627

2728
impl CredManagementParams {
@@ -68,7 +69,7 @@ pub(crate) enum CredManagementCommand {
6869
EnumerateCredentialsBegin(RpIdHash),
6970
EnumerateCredentialsGetNextCredential,
7071
DeleteCredential(PublicKeyCredentialDescriptor),
71-
UpdateUserInformation((PublicKeyCredentialDescriptor, User)),
72+
UpdateUserInformation((PublicKeyCredentialDescriptor, PublicKeyCredentialUserEntity)),
7273
}
7374

7475
impl CredManagementCommand {
@@ -157,7 +158,7 @@ pub struct CredentialManagementResponse {
157158
/// Total number of RPs present on the authenticator
158159
pub total_rps: Option<u64>,
159160
/// User Information
160-
pub user: Option<User>,
161+
pub user: Option<PublicKeyCredentialUserEntity>,
161162
/// Credential ID
162163
pub credential_id: Option<PublicKeyCredentialDescriptor>,
163164
/// Public key of the credential.
@@ -182,7 +183,7 @@ pub struct CredentialRpListEntry {
182183
#[derive(Debug, PartialEq, Eq, Serialize)]
183184
pub struct CredentialListEntry {
184185
/// User Information
185-
pub user: User,
186+
pub user: PublicKeyCredentialUserEntity,
186187
/// Credential ID
187188
pub credential_id: PublicKeyCredentialDescriptor,
188189
/// Public key of the credential.

src/ctap2/commands/get_assertion.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::ctap2::commands::get_next_assertion::GetNextAssertion;
1313
use crate::ctap2::commands::make_credentials::UserVerification;
1414
use crate::ctap2::server::{
1515
AuthenticationExtensionsClientInputs, AuthenticationExtensionsClientOutputs,
16-
PublicKeyCredentialDescriptor, RelyingPartyWrapper, RpIdHash, User,
16+
PublicKeyCredentialDescriptor, PublicKeyCredentialUserEntity, RelyingPartyWrapper, RpIdHash,
1717
UserVerificationRequirement,
1818
};
1919
use crate::ctap2::utils::{read_be_u32, read_byte};
@@ -449,7 +449,7 @@ pub struct Assertion {
449449
* mandatory in CTAP2.1 */
450450
pub auth_data: AuthenticatorData,
451451
pub signature: Vec<u8>,
452-
pub user: Option<User>,
452+
pub user: Option<PublicKeyCredentialUserEntity>,
453453
}
454454

455455
impl From<GetAssertionResponse> for Assertion {
@@ -524,7 +524,7 @@ pub struct GetAssertionResponse {
524524
pub credentials: Option<PublicKeyCredentialDescriptor>,
525525
pub auth_data: AuthenticatorData,
526526
pub signature: Vec<u8>,
527-
pub user: Option<User>,
527+
pub user: Option<PublicKeyCredentialUserEntity>,
528528
pub number_of_credentials: Option<usize>,
529529
}
530530

@@ -628,7 +628,8 @@ pub mod test {
628628
do_credential_list_filtering_ctap1, do_credential_list_filtering_ctap2,
629629
};
630630
use crate::ctap2::server::{
631-
PublicKeyCredentialDescriptor, RelyingParty, RelyingPartyWrapper, RpIdHash, Transport, User,
631+
PublicKeyCredentialDescriptor, PublicKeyCredentialUserEntity, RelyingParty,
632+
RelyingPartyWrapper, RpIdHash, Transport,
632633
};
633634
use crate::transport::device_selector::Device;
634635
use crate::transport::hid::HIDDevice;
@@ -778,7 +779,7 @@ pub mod test {
778779
0x47, 0xf1, 0x8d, 0xb4, 0x74, 0xc7, 0x47, 0x90, 0xea, 0xab, 0xb1, 0x44, 0x11, 0xe7,
779780
0xa0,
780781
],
781-
user: Some(User {
782+
user: Some(PublicKeyCredentialUserEntity {
782783
id: vec![
783784
0x30, 0x82, 0x01, 0x93, 0x30, 0x82, 0x01, 0x38, 0xa0, 0x03, 0x02, 0x01, 0x02,
784785
0x30, 0x82, 0x01, 0x93, 0x30, 0x82, 0x01, 0x38, 0xa0, 0x03, 0x02, 0x01, 0x02,

src/ctap2/commands/make_credentials.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ use crate::ctap2::client_data::ClientDataHash;
1515
use crate::ctap2::server::{
1616
AuthenticationExtensionsClientInputs, AuthenticationExtensionsClientOutputs,
1717
CredentialProtectionPolicy, PublicKeyCredentialDescriptor, PublicKeyCredentialParameters,
18-
RelyingParty, RelyingPartyWrapper, RpIdHash, User, UserVerificationRequirement,
18+
PublicKeyCredentialUserEntity, RelyingParty, RelyingPartyWrapper, RpIdHash,
19+
UserVerificationRequirement,
1920
};
2021
use crate::ctap2::utils::{read_byte, serde_parse_err};
2122
use crate::errors::AuthenticatorError;
@@ -260,7 +261,7 @@ pub struct MakeCredentials {
260261
pub client_data_hash: ClientDataHash,
261262
pub rp: RelyingPartyWrapper,
262263
// Note(baloo): If none -> ctap1
263-
pub user: Option<User>,
264+
pub user: Option<PublicKeyCredentialUserEntity>,
264265
pub pub_cred_params: Vec<PublicKeyCredentialParameters>,
265266
pub exclude_list: Vec<PublicKeyCredentialDescriptor>,
266267

@@ -281,7 +282,7 @@ impl MakeCredentials {
281282
pub fn new(
282283
client_data_hash: ClientDataHash,
283284
rp: RelyingPartyWrapper,
284-
user: Option<User>,
285+
user: Option<PublicKeyCredentialUserEntity>,
285286
pub_cred_params: Vec<PublicKeyCredentialParameters>,
286287
exclude_list: Vec<PublicKeyCredentialDescriptor>,
287288
options: MakeCredentialsOptions,
@@ -564,7 +565,7 @@ pub(crate) fn dummy_make_credentials_cmd() -> MakeCredentials {
564565
id: String::from("make.me.blink"),
565566
..Default::default()
566567
}),
567-
Some(User {
568+
Some(PublicKeyCredentialUserEntity {
568569
id: vec![0],
569570
name: Some(String::from("make.me.blink")),
570571
..Default::default()
@@ -597,7 +598,8 @@ pub mod test {
597598
use crate::ctap2::commands::{RequestCtap1, RequestCtap2};
598599
use crate::ctap2::server::RpIdHash;
599600
use crate::ctap2::server::{
600-
PublicKeyCredentialParameters, RelyingParty, RelyingPartyWrapper, User,
601+
PublicKeyCredentialParameters, PublicKeyCredentialUserEntity, RelyingParty,
602+
RelyingPartyWrapper,
601603
};
602604
use crate::transport::device_selector::Device;
603605
use crate::transport::hid::HIDDevice;
@@ -620,7 +622,7 @@ pub mod test {
620622
id: String::from("example.com"),
621623
name: Some(String::from("Acme")),
622624
}),
623-
Some(User {
625+
Some(PublicKeyCredentialUserEntity {
624626
id: base64::engine::general_purpose::URL_SAFE
625627
.decode("MIIBkzCCATigAwIBAjCCAZMwggE4oAMCAQIwggGTMII=")
626628
.unwrap(),
@@ -677,7 +679,7 @@ pub mod test {
677679
id: String::from("example.com"),
678680
name: Some(String::from("Acme")),
679681
}),
680-
Some(User {
682+
Some(PublicKeyCredentialUserEntity {
681683
id: base64::engine::general_purpose::URL_SAFE
682684
.decode("MIIBkzCCATigAwIBAjCCAZMwggE4oAMCAQIwggGTMII=")
683685
.unwrap(),

src/ctap2/server.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,9 @@ impl RpIdHash {
4040
}
4141
}
4242

43+
// NOTE: WebAuthn requires all fields and CTAP2 does not.
4344
#[derive(Debug, Serialize, Clone, Default, Deserialize, PartialEq, Eq)]
4445
pub struct RelyingParty {
45-
// TODO(baloo): spec is wrong !!!!111
46-
// https://fidoalliance.org/specs/fido-v2.0-ps-20190130/fido-client-to-authenticator-protocol-v2.0-ps-20190130.html#commands
47-
// in the example "A PublicKeyCredentialRpEntity DOM object defined as follows:"
48-
// inconsistent with https://w3c.github.io/webauthn/#sctn-rp-credential-params
4946
pub id: String,
5047
#[serde(skip_serializing_if = "Option::is_none")]
5148
pub name: Option<String>,
@@ -94,9 +91,9 @@ impl RelyingPartyWrapper {
9491
}
9592
}
9693

97-
// TODO(baloo): should we rename this PublicKeyCredentialUserEntity ?
94+
// NOTE: WebAuthn requires all fields and CTAP2 does not.
9895
#[derive(Debug, Serialize, Clone, Eq, PartialEq, Deserialize, Default)]
99-
pub struct User {
96+
pub struct PublicKeyCredentialUserEntity {
10097
#[serde(with = "serde_bytes")]
10198
pub id: Vec<u8>,
10299
pub name: Option<String>,
@@ -406,13 +403,13 @@ pub struct AuthenticationExtensionsClientOutputs {
406403
#[cfg(test)]
407404
mod test {
408405
use super::{
409-
COSEAlgorithm, PublicKeyCredentialDescriptor, PublicKeyCredentialParameters, RelyingParty,
410-
Transport, User,
406+
COSEAlgorithm, PublicKeyCredentialDescriptor, PublicKeyCredentialParameters,
407+
PublicKeyCredentialUserEntity, RelyingParty, Transport,
411408
};
412409
use serde_cbor::from_slice;
413410

414-
fn create_user() -> User {
415-
User {
411+
fn create_user() -> PublicKeyCredentialUserEntity {
412+
PublicKeyCredentialUserEntity {
416413
id: vec![
417414
0x30, 0x82, 0x01, 0x93, 0x30, 0x82, 0x01, 0x38, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x30,
418415
0x82, 0x01, 0x93, 0x30, 0x82, 0x01, 0x38, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x30, 0x82,
@@ -479,7 +476,7 @@ mod test {
479476
0x69, 0x74, 0x68, // ...
480477
];
481478
let expected = create_user();
482-
let actual: User = from_slice(&input).unwrap();
479+
let actual: PublicKeyCredentialUserEntity = from_slice(&input).unwrap();
483480
assert_eq!(expected, actual);
484481
}
485482

@@ -519,7 +516,7 @@ mod test {
519516

520517
#[test]
521518
fn serialize_user_nodisplayname() {
522-
let user = User {
519+
let user = PublicKeyCredentialUserEntity {
523520
id: vec![
524521
0x30, 0x82, 0x01, 0x93, 0x30, 0x82, 0x01, 0x38, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x30,
525522
0x82, 0x01, 0x93, 0x30, 0x82, 0x01, 0x38, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x30, 0x82,

src/status_update.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{
77
get_info::AuthenticatorInfo,
88
PinUvAuthResult,
99
},
10-
server::{PublicKeyCredentialDescriptor, User},
10+
server::{PublicKeyCredentialDescriptor, PublicKeyCredentialUserEntity},
1111
},
1212
BioEnrollmentResult, CredentialManagementResult,
1313
};
@@ -18,7 +18,7 @@ use std::sync::mpsc::Sender;
1818
pub enum CredManagementCmd {
1919
GetCredentials,
2020
DeleteCredential(PublicKeyCredentialDescriptor),
21-
UpdateUserInformation(PublicKeyCredentialDescriptor, User),
21+
UpdateUserInformation(PublicKeyCredentialDescriptor, PublicKeyCredentialUserEntity),
2222
}
2323

2424
#[derive(Debug, Deserialize, DeriveSer)]

0 commit comments

Comments
 (0)