Skip to content

Commit f45c5b6

Browse files
committed
Add CredentialExcluded error
1 parent bbb0b99 commit f45c5b6

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

credentialsd-common/src/model.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ pub enum Error {
274274
AuthenticatorError,
275275
/// No matching credentials were found on the device.
276276
NoCredentials,
277+
/// Credential was already registered with this device (credential ID contained in excludeCredentials)
278+
CredentialExcluded,
277279
/// Too many incorrect PIN attempts, and authenticator must be removed and
278280
/// reinserted to continue any more PIN attempts.
279281
///
@@ -292,6 +294,7 @@ impl Display for Error {
292294
match self {
293295
Self::AuthenticatorError => f.write_str("AuthenticatorError"),
294296
Self::NoCredentials => f.write_str("NoCredentials"),
297+
Self::CredentialExcluded => f.write_str("CredentialExcluded"),
295298
Self::PinAttemptsExhausted => f.write_str("PinAttemptsExhausted"),
296299
Self::Internal(s) => write!(f, "InternalError: {s}"),
297300
}

credentialsd-common/src/server.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,9 @@ pub enum ServiceError {
336336
/// No matching credentials were found on the device.
337337
NoCredentials,
338338

339+
/// Credential was already registered with this device (credential ID contained in excludeCredentials)
340+
CredentialExcluded,
341+
339342
/// Too many incorrect PIN attempts, and authenticator must be removed and
340343
/// reinserted to continue any more PIN attempts.
341344
///
@@ -363,6 +366,7 @@ impl From<ServiceError> for crate::model::Error {
363366
match value {
364367
ServiceError::AuthenticatorError => Self::AuthenticatorError,
365368
ServiceError::NoCredentials => Self::NoCredentials,
369+
ServiceError::CredentialExcluded => Self::CredentialExcluded,
366370
ServiceError::PinAttemptsExhausted => Self::PinAttemptsExhausted,
367371
// TODO: this is bogus, we should refactor to remove the tuple field
368372
// and let the client decide how to render the error.
@@ -439,6 +443,7 @@ impl TryFrom<UsbState> for crate::model::UsbState {
439443
match error_code.as_ref() {
440444
"AuthenticatorError" => ServiceError::AuthenticatorError,
441445
"NoCredentials" => ServiceError::NoCredentials,
446+
"CredentialExcluded" => ServiceError::CredentialExcluded,
442447
"PinAttemptsExhausted" => ServiceError::PinAttemptsExhausted,
443448
_ => ServiceError::Internal,
444449
}

credentialsd-ui/src/gui/view_model/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ impl<F: FlowController + Send> ViewModel<F> {
230230
Error::AuthenticatorError | Error::Internal(_) => {
231231
"Something went wrong while retrieving a credential. Please try again later or use a different authenticator."
232232
}
233+
Error::CredentialExcluded => {
234+
"This credential is already registered on this authenticator."
235+
}
233236
});
234237
self.tx_update
235238
.send(ViewUpdate::Failed(error_msg))

credentialsd/src/credential_service/usb.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ async fn handle_events(
343343
.map_err(|err| match err {
344344
WebAuthnError::Ctap(CtapError::PINAuthBlocked) => Error::PinAttemptsExhausted,
345345
WebAuthnError::Ctap(CtapError::NoCredentials) => Error::NoCredentials,
346+
WebAuthnError::Ctap(CtapError::CredentialExcluded) => Error::CredentialExcluded,
346347
_ => Error::AuthenticatorError,
347348
});
348349
if let Err(err) = signal_tx.send(response).await {

0 commit comments

Comments
 (0)