Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial support for ykman 5.5 and fix error reporting #371

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions ykman-gui/py/yubikey.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@
if int(ykman_v.split(".")[0] ) > 4:
from yubikit.support import get_name
from ykman.device import list_all_devices, scan_devices
from ykman.otp import (
_PrepareUploadFailed as PrepareUploadFailed
, _prepare_upload_key as prepare_upload_key, generate_static_pw)
if int(ykman_v.split(".")[0]) == 5 and int(ykman_v.split(".")[1]) < 5:
from ykman.otp import (
_PrepareUploadFailed as PrepareUploadFailed
, _prepare_upload_key as prepare_upload_key)
from ykman.otp import generate_static_pw
else:
from ykman import connect_to_device, scan_devices, get_name
from ykman.otp import PrepareUploadFailed, prepare_upload_key, generate_static_pw
Expand Down Expand Up @@ -401,6 +403,12 @@ def program_otp(self, slot, public_id, private_id, key, upload=False,

with self._open_device([OtpConnection]) as conn:
if upload:
# Automated YubiCloud upload support has been ended. It's not supported in ykman>=5.5.0.
ykman_v_major = int(ykman_v.split(".")[0])
ykman_v_minor = int(ykman_v.split(".")[1])
if ykman_v_major > 5 or (ykman_v_major == 5 and ykman_v_minor >= 5):
return failure('yubicloud_upload_not_supported')

try:
upload_url = prepare_upload_key(
key, public_id, private_id,
Expand Down
4 changes: 2 additions & 2 deletions ykman-gui/qml/ContentStack.qml
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ StackView {
SlotUtils.slotNameCapitalized(views.selectedSlot)))
}

function otpFailedToConfigureErrorPopup(error) {
function otpFailedToConfigureErrorPopup(resp) {
snackbarError.show(qsTr("Failed to configure %1. %2").arg(
SlotUtils.slotNameCapitalized(
views.selectedSlot)).arg(snackbarError.getDefaultMessage(error)))
views.selectedSlot)).arg(snackbarError.getDefaultMessage(resp)))
}

function snackbarErrorMessage(error) {
Expand Down
3 changes: 1 addition & 2 deletions ykman-gui/qml/OtpChalRespView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ ColumnLayout {
if (resp.error_id === 'write error') {
views.otpWriteError()
} else {
views.otpFailedToConfigureErrorPopup(
resp.error_id)
views.otpFailedToConfigureErrorPopup(resp)
}
}
})
Expand Down
3 changes: 1 addition & 2 deletions ykman-gui/qml/OtpOathHotpView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ ColumnLayout {
if (resp.error_id === 'write error') {
views.otpWriteError()
} else {
views.otpFailedToConfigureErrorPopup(
resp)
views.otpFailedToConfigureErrorPopup(resp)
}
}
})
Expand Down
3 changes: 1 addition & 2 deletions ykman-gui/qml/OtpStaticPasswordView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ ColumnLayout {
if (resp.error_id === 'write error') {
views.otpWriteError()
} else {
views.otpFailedToConfigureErrorPopup(
resp.error_id)
views.otpFailedToConfigureErrorPopup(resp)
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion ykman-gui/qml/OtpView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ ColumnLayout {
if (resp.error_id === 'write error') {
views.otpWriteError()
} else {
views.otpFailedToConfigureErrorPopup(resp.error_id)
views.otpFailedToConfigureErrorPopup(resp)
}
}
})
Expand Down
3 changes: 1 addition & 2 deletions ykman-gui/qml/OtpYubiOtpView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ ColumnLayout {
getUploadErrorMessage(
resp.upload_errors[0])))
} else {
views.otpFailedToConfigureErrorPopup(
resp.error_id)
views.otpFailedToConfigureErrorPopup(resp)
}
}
})
Expand Down
2 changes: 2 additions & 0 deletions ykman-gui/qml/SnackBarError.qml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ SnackBar {
return qsTr("Failed to parse file")
case 'incorrect_padding':
return qsTr("Incorrect padding.")
case 'yubicloud_upload_not_supported':
return qsTr("Automated YubiCloud upload support has been ended.")
}
}

Expand Down