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

Allow disabling the trailing Enter when setting a static password #349

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
5 changes: 3 additions & 2 deletions ykman-gui/py/yubikey.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,14 @@ def program_challenge_response(self, slot, key, touch):
return failure("write error")
return success()

def program_static_password(self, slot, key, keyboard_layout):
def program_static_password(self, slot, key, enter, keyboard_layout):
with self._open_device([OtpConnection]) as conn:
session = YubiOtpSession(conn)
scan_codes = encode(key, KEYBOARD_LAYOUT[keyboard_layout])
slot_config = StaticPasswordSlotConfiguration(scan_codes).append_cr(enter)

try:
session.put_configuration(slot, StaticPasswordSlotConfiguration(scan_codes))
session.put_configuration(slot, slot_config)
except CommandError as e:
logger.debug("Failed to program static password", exc_info=e)
return failure("write error")
Expand Down
15 changes: 14 additions & 1 deletion ykman-gui/qml/OtpStaticPasswordView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import QtQuick.Controls.Material 2.2
ColumnLayout {

property string keyboardLayout: allowNonModhex.checked ? 'US' : 'MODHEX'
property bool enter: appendCR.checked

function finish() {
if (views.selectedSlotConfigured()) {
Expand All @@ -17,7 +18,7 @@ ColumnLayout {
}

function programStaticPassword() {
yubiKey.programStaticPassword(views.selectedSlot, passwordInput.text,
yubiKey.programStaticPassword(views.selectedSlot, passwordInput.text, enter,
keyboardLayout, function (resp) {
if (resp.success) {
views.otp()
Expand Down Expand Up @@ -80,6 +81,7 @@ ColumnLayout {
toolTipText: qsTr("Generate a random password")
}
}

CheckBox {
id: allowNonModhex
text: qsTr("Allow any character")
Expand All @@ -91,6 +93,17 @@ ColumnLayout {
ToolTip.text: qsTr("By default only modhex characters are allowed, enable this option to allow any (US Layout) characters")
}

CheckBox {
id: appendCR
text: qsTr("Append a CR to the password")
checked: true
font.pixelSize: constants.h3
Material.foreground: yubicoBlue
ToolTip.delay: 1000
ToolTip.visible: hovered
ToolTip.text: qsTr("After entering the password, simulate pressing Enter or Return")
}

ButtonsBar {
finishCallback: finish
finishEnabled: passwordInput.acceptableInput
Expand Down
4 changes: 2 additions & 2 deletions ykman-gui/qml/YubiKey.qml
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,9 @@ Python {
[slot, key, touch], cb)
}

function programStaticPassword(slot, password, keyboardLayout, cb) {
function programStaticPassword(slot, password, enter, keyboardLayout, cb) {
doCall('yubikey.controller.program_static_password',
[slot, password, keyboardLayout], cb)
[slot, password, enter, keyboardLayout], cb)
}

function programOathHotp(slot, key, digits, cb) {
Expand Down