This commit is contained in:
Elias Bonnici 2023-12-20 14:42:25 +01:00
commit 1d9c7b4f49
No known key found for this signature in database
GPG Key ID: 5EAC28EA3F980CCF
8 changed files with 87 additions and 5 deletions

View File

@ -47,6 +47,21 @@ class PinValidationException(RpcException):
)
class InactivityException(RpcException):
def __init__(self):
super().__init__(
"user-action-timeout",
"Failed to add fingerprint due to user inactivity.",
)
class KeyMismatchException(RpcException):
def __init__(self):
super().__init__(
"key-mismatch", "Re-inserted YubiKey does not match initial device"
)
def _ctap_id(ctap):
return (ctap.info.aaguid, ctap.info.firmware_version)
@ -163,8 +178,12 @@ class Ctap2Node(RpcNode):
logger.debug("Performing reset...")
self.ctap = Ctap2(connection)
if target != _ctap_id(self.ctap):
raise ValueError("Re-inserted YubiKey does not match initial device")
self.ctap.reset(event=event)
raise KeyMismatchException()
try:
self.ctap.reset(event=event)
except CtapError as e:
if e.code == CtapError.ERR.USER_ACTION_TIMEOUT:
raise InactivityException()
self._info = self.ctap.get_info()
self._auth_blocked = False
self._token = None
@ -340,6 +359,9 @@ class FingerprintsNode(RpcNode):
signal("capture", dict(remaining=enroller.remaining))
except CaptureError as e:
signal("capture-error", dict(code=e.code))
except CtapError as e:
if e.code == CtapError.ERR.USER_ACTION_TIMEOUT:
raise InactivityException()
if name:
self.bio.set_name(template_id, name)
self._templates[template_id] = name

View File

@ -113,16 +113,23 @@ class _AddFingerprintDialogState extends ConsumerState<AddFingerprintDialog>
}, onError: (error, stacktrace) {
_log.error('Error adding fingerprint', error, stacktrace);
Navigator.of(context).pop();
final l10n = AppLocalizations.of(context)!;
final String errorMessage;
// TODO: Make this cleaner than importing desktop specific RpcError.
if (error is RpcError) {
errorMessage = error.message;
if (error.status == 'user-action-timeout') {
errorMessage = l10n.l_user_action_timeout_error;
} else if (error.status == 'connection-error') {
errorMessage = l10n.l_failed_connecting_to_fido;
} else {
errorMessage = error.message;
}
} else {
errorMessage = error.toString();
}
showMessage(
context,
'Error adding fingerprint: $errorMessage',
l10n.l_adding_fingerprint_failed(errorMessage),
duration: const Duration(seconds: 4),
);
});

View File

@ -97,7 +97,15 @@ class _ResetDialogState extends ConsumerState<ResetDialog> {
final String errorMessage;
// TODO: Make this cleaner than importing desktop specific RpcError.
if (e is RpcError) {
errorMessage = e.message;
if (e.status == 'connection-error') {
errorMessage = l10n.l_failed_connecting_to_fido;
} else if (e.status == 'key-mismatch') {
errorMessage = l10n.l_wrong_inserted_yk_error;
} else if (e.status == 'user-action-timeout') {
errorMessage = l10n.l_user_action_timeout_error;
} else {
errorMessage = e.message;
}
} else {
errorMessage = e.toString();
}

View File

@ -406,6 +406,10 @@
"s_fingerprints": "Fingerabdrücke",
"l_fingerprint_captured": "Fingerabdruck erfolgreich aufgenommen!",
"s_fingerprint_added": "Fingerabdruck hinzugefügt",
"l_adding_fingerprint_failed": null,
"@l_adding_fingerprint_failed": {
"placeholders": {}
},
"l_setting_name_failed": "Fehler beim Setzen des Namens: {message}",
"@l_setting_name_failed": {
"placeholders": {
@ -441,6 +445,11 @@
"p_press_fingerprint_begin": "Drücken Sie Ihren Finger gegen den YubiKey um zu beginnen.",
"p_will_change_label_fp": "Das ändert die Beschriftung des Fingerabdrucks.",
"@_fido_errors": {},
"l_user_action_timeout_error": null,
"l_wrong_inserted_yk_error": null,
"l_failed_connecting_to_fido": null,
"@_certificates": {},
"s_certificate": null,
"s_csr": null,

View File

@ -406,6 +406,10 @@
"s_fingerprints": "Fingerprints",
"l_fingerprint_captured": "Fingerprint captured successfully!",
"s_fingerprint_added": "Fingerprint added",
"l_adding_fingerprint_failed": "Error adding fingerprint: {message}",
"@l_adding_fingerprint_failed": {
"placeholders": {}
},
"l_setting_name_failed": "Error setting name: {message}",
"@l_setting_name_failed": {
"placeholders": {
@ -441,6 +445,11 @@
"p_press_fingerprint_begin": "Press your finger against the YubiKey to begin.",
"p_will_change_label_fp": "This will change the label of the fingerprint.",
"@_fido_errors": {},
"l_user_action_timeout_error": "Failed due to user inactivity",
"l_wrong_inserted_yk_error": "Re-inserted YubiKey does not match initial device",
"l_failed_connecting_to_fido": "Failed connecting to FIDO interface",
"@_certificates": {},
"s_certificate": "Certificate",
"s_csr": "CSR",

View File

@ -406,6 +406,10 @@
"s_fingerprints": "Empreintes",
"l_fingerprint_captured": "Empreinte capturée avec succès!",
"s_fingerprint_added": "Empreinte ajoutée",
"l_adding_fingerprint_failed": null,
"@l_adding_fingerprint_failed": {
"placeholders": {}
},
"l_setting_name_failed": "Erreur lors de l'ajout du nom: {message}",
"@l_setting_name_failed": {
"placeholders": {
@ -441,6 +445,11 @@
"p_press_fingerprint_begin": "Posez votre doigt sur votre YubiKey pour commencer.",
"p_will_change_label_fp": "Cette action changera la description de votre empreinte.",
"@_fido_errors": {},
"l_user_action_timeout_error": null,
"l_wrong_inserted_yk_error": null,
"l_failed_connecting_to_fido": null,
"@_certificates": {},
"s_certificate": "Certificat",
"s_csr": "CSR",

View File

@ -406,6 +406,10 @@
"s_fingerprints": "指紋",
"l_fingerprint_captured": "指紋の取得に成功しました!",
"s_fingerprint_added": "指紋が追加されました",
"l_adding_fingerprint_failed": null,
"@l_adding_fingerprint_failed": {
"placeholders": {}
},
"l_setting_name_failed": "名前設定時名エラー:{message}",
"@l_setting_name_failed": {
"placeholders": {
@ -441,6 +445,11 @@
"p_press_fingerprint_begin": "YubiKeyに指を押し当てて開始します",
"p_will_change_label_fp": "これにより指紋のラベルが変更されます",
"@_fido_errors": {},
"l_user_action_timeout_error": null,
"l_wrong_inserted_yk_error": null,
"l_failed_connecting_to_fido": null,
"@_certificates": {},
"s_certificate": "証明書",
"s_csr": "CSR",

View File

@ -406,6 +406,10 @@
"s_fingerprints": "Odciski palców",
"l_fingerprint_captured": "Odcisk palca zarejestrowany pomyślnie!",
"s_fingerprint_added": "Dodano odcisk palca",
"l_adding_fingerprint_failed": null,
"@l_adding_fingerprint_failed": {
"placeholders": {}
},
"l_setting_name_failed": "Błąd ustawienia nazwy: {message}",
"@l_setting_name_failed": {
"placeholders": {
@ -441,6 +445,11 @@
"p_press_fingerprint_begin": "Przytrzymaj palec na kluczu YubiKey, aby rozpocząć.",
"p_will_change_label_fp": "Spowoduje to zmianę etykiety odcisku palca.",
"@_fido_errors": {},
"l_user_action_timeout_error": null,
"l_wrong_inserted_yk_error": null,
"l_failed_connecting_to_fido": null,
"@_certificates": {},
"s_certificate": "Certyfikat",
"s_csr": "CSR",