mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-07 19:59:14 -04:00
fix(lock): avoid U2F PAM polling in OR mode (#2459)
This commit is contained in:
@@ -73,6 +73,10 @@ Item {
|
|||||||
return pam && (pam.u2fState === "waiting" || pam.u2fState === "insert") && !pam.u2fPending;
|
return pam && (pam.u2fState === "waiting" || pam.u2fState === "insert") && !pam.u2fPending;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function canStartSecurityKeyUnlock() {
|
||||||
|
return !demoMode && pam && pam.u2f && pam.u2f.available && SettingsData.enableU2f && SettingsData.u2fMode === "or" && !pam.passwd.active && !pam.u2f.active && !pam.u2fPending && !root.unlocking;
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
WeatherService.addRef();
|
WeatherService.addRef();
|
||||||
UserInfoService.getUserInfo();
|
UserInfoService.getUserInfo();
|
||||||
@@ -761,6 +765,9 @@ Item {
|
|||||||
if (enterButton.visible) {
|
if (enterButton.visible) {
|
||||||
margin += enterButton.width + 2;
|
margin += enterButton.width + 2;
|
||||||
}
|
}
|
||||||
|
if (securityKeyButton.visible) {
|
||||||
|
margin += securityKeyButton.width;
|
||||||
|
}
|
||||||
if (virtualKeyboardButton.visible) {
|
if (virtualKeyboardButton.visible) {
|
||||||
margin += virtualKeyboardButton.width;
|
margin += virtualKeyboardButton.width;
|
||||||
}
|
}
|
||||||
@@ -854,7 +861,7 @@ Item {
|
|||||||
|
|
||||||
anchors.left: lockIconContainer.right
|
anchors.left: lockIconContainer.right
|
||||||
anchors.leftMargin: Theme.spacingM
|
anchors.leftMargin: Theme.spacingM
|
||||||
anchors.right: (revealButton.visible ? revealButton.left : (virtualKeyboardButton.visible ? virtualKeyboardButton.left : (enterButton.visible ? enterButton.left : (loadingSpinner.visible ? loadingSpinner.left : parent.right))))
|
anchors.right: (revealButton.visible ? revealButton.left : (virtualKeyboardButton.visible ? virtualKeyboardButton.left : (securityKeyButton.visible ? securityKeyButton.left : (enterButton.visible ? enterButton.left : (loadingSpinner.visible ? loadingSpinner.left : parent.right)))))
|
||||||
anchors.rightMargin: 2
|
anchors.rightMargin: 2
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
text: {
|
text: {
|
||||||
@@ -896,7 +903,7 @@ Item {
|
|||||||
StyledText {
|
StyledText {
|
||||||
anchors.left: lockIconContainer.right
|
anchors.left: lockIconContainer.right
|
||||||
anchors.leftMargin: Theme.spacingM
|
anchors.leftMargin: Theme.spacingM
|
||||||
anchors.right: (revealButton.visible ? revealButton.left : (virtualKeyboardButton.visible ? virtualKeyboardButton.left : (enterButton.visible ? enterButton.left : (loadingSpinner.visible ? loadingSpinner.left : parent.right))))
|
anchors.right: (revealButton.visible ? revealButton.left : (virtualKeyboardButton.visible ? virtualKeyboardButton.left : (securityKeyButton.visible ? securityKeyButton.left : (enterButton.visible ? enterButton.left : (loadingSpinner.visible ? loadingSpinner.left : parent.right)))))
|
||||||
anchors.rightMargin: 2
|
anchors.rightMargin: 2
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
text: {
|
text: {
|
||||||
@@ -926,7 +933,7 @@ Item {
|
|||||||
DankActionButton {
|
DankActionButton {
|
||||||
id: revealButton
|
id: revealButton
|
||||||
|
|
||||||
anchors.right: virtualKeyboardButton.visible ? virtualKeyboardButton.left : (enterButton.visible ? enterButton.left : (loadingSpinner.visible ? loadingSpinner.left : parent.right))
|
anchors.right: virtualKeyboardButton.visible ? virtualKeyboardButton.left : (securityKeyButton.visible ? securityKeyButton.left : (enterButton.visible ? enterButton.left : (loadingSpinner.visible ? loadingSpinner.left : parent.right)))
|
||||||
anchors.rightMargin: 0
|
anchors.rightMargin: 0
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
iconName: parent.showPassword ? "visibility_off" : "visibility"
|
iconName: parent.showPassword ? "visibility_off" : "visibility"
|
||||||
@@ -936,10 +943,26 @@ Item {
|
|||||||
onClicked: parent.showPassword = !parent.showPassword
|
onClicked: parent.showPassword = !parent.showPassword
|
||||||
}
|
}
|
||||||
DankActionButton {
|
DankActionButton {
|
||||||
id: virtualKeyboardButton
|
id: securityKeyButton
|
||||||
|
|
||||||
anchors.right: enterButton.visible ? enterButton.left : (loadingSpinner.visible ? loadingSpinner.left : parent.right)
|
anchors.right: enterButton.visible ? enterButton.left : (loadingSpinner.visible ? loadingSpinner.left : parent.right)
|
||||||
anchors.rightMargin: enterButton.visible ? 0 : Theme.spacingS
|
anchors.rightMargin: 0
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
iconName: "passkey"
|
||||||
|
buttonSize: 32
|
||||||
|
visible: root.canStartSecurityKeyUnlock()
|
||||||
|
enabled: visible
|
||||||
|
onClicked: {
|
||||||
|
passwordField.text = "";
|
||||||
|
root.passwordBuffer = "";
|
||||||
|
pam.u2f.startForAlternativeAuth();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DankActionButton {
|
||||||
|
id: virtualKeyboardButton
|
||||||
|
|
||||||
|
anchors.right: securityKeyButton.visible ? securityKeyButton.left : (enterButton.visible ? enterButton.left : (loadingSpinner.visible ? loadingSpinner.left : parent.right))
|
||||||
|
anchors.rightMargin: securityKeyButton.visible || enterButton.visible ? 0 : Theme.spacingS
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
iconName: "keyboard"
|
iconName: "keyboard"
|
||||||
buttonSize: 32
|
buttonSize: 32
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ Scope {
|
|||||||
property string fprintState
|
property string fprintState
|
||||||
property string u2fState
|
property string u2fState
|
||||||
property bool u2fPending: false
|
property bool u2fPending: false
|
||||||
|
property string u2fPendingMode
|
||||||
property string buffer
|
property string buffer
|
||||||
|
|
||||||
signal flashMsg
|
signal flashMsg
|
||||||
@@ -35,6 +36,7 @@ Scope {
|
|||||||
passwdActiveTimeout.running = false;
|
passwdActiveTimeout.running = false;
|
||||||
unlockRequestTimeout.running = false;
|
unlockRequestTimeout.running = false;
|
||||||
root.u2fPending = false;
|
root.u2fPending = false;
|
||||||
|
root.u2fPendingMode = "";
|
||||||
root.u2fState = "";
|
root.u2fState = "";
|
||||||
root.unlockInProgress = false;
|
root.unlockInProgress = false;
|
||||||
}
|
}
|
||||||
@@ -58,6 +60,7 @@ Scope {
|
|||||||
u2fErrorRetry.running = false;
|
u2fErrorRetry.running = false;
|
||||||
u2fPendingTimeout.running = false;
|
u2fPendingTimeout.running = false;
|
||||||
root.u2fPending = false;
|
root.u2fPending = false;
|
||||||
|
root.u2fPendingMode = "";
|
||||||
root.u2fState = "";
|
root.u2fState = "";
|
||||||
unlockRequestTimeout.restart();
|
unlockRequestTimeout.restart();
|
||||||
unlockRequested();
|
unlockRequested();
|
||||||
@@ -79,6 +82,7 @@ Scope {
|
|||||||
u2fErrorRetry.running = false;
|
u2fErrorRetry.running = false;
|
||||||
u2fPendingTimeout.running = false;
|
u2fPendingTimeout.running = false;
|
||||||
root.u2fPending = false;
|
root.u2fPending = false;
|
||||||
|
root.u2fPendingMode = "";
|
||||||
root.u2fState = "";
|
root.u2fState = "";
|
||||||
fprint.checkAvail();
|
fprint.checkAvail();
|
||||||
}
|
}
|
||||||
@@ -142,6 +146,7 @@ Scope {
|
|||||||
unlockRequestTimeout.running = false;
|
unlockRequestTimeout.running = false;
|
||||||
root.unlockInProgress = false;
|
root.unlockInProgress = false;
|
||||||
root.u2fPending = false;
|
root.u2fPending = false;
|
||||||
|
root.u2fPendingMode = "";
|
||||||
root.u2fState = "";
|
root.u2fState = "";
|
||||||
u2fPendingTimeout.running = false;
|
u2fPendingTimeout.running = false;
|
||||||
u2f.abort();
|
u2f.abort();
|
||||||
@@ -243,9 +248,8 @@ Scope {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SettingsData.u2fMode === "or") {
|
if (SettingsData.u2fMode === "or")
|
||||||
start();
|
abort();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function startForSecondFactor(): void {
|
function startForSecondFactor(): void {
|
||||||
@@ -255,6 +259,18 @@ Scope {
|
|||||||
}
|
}
|
||||||
abort();
|
abort();
|
||||||
root.u2fPending = true;
|
root.u2fPending = true;
|
||||||
|
root.u2fPendingMode = "and";
|
||||||
|
root.u2fState = "";
|
||||||
|
u2fPendingTimeout.restart();
|
||||||
|
start();
|
||||||
|
}
|
||||||
|
|
||||||
|
function startForAlternativeAuth(): void {
|
||||||
|
if (!available || !SettingsData.enableU2f || SettingsData.u2fMode !== "or" || root.unlockInProgress || passwd.active || active)
|
||||||
|
return;
|
||||||
|
abort();
|
||||||
|
root.u2fPending = true;
|
||||||
|
root.u2fPendingMode = "or";
|
||||||
root.u2fState = "";
|
root.u2fState = "";
|
||||||
u2fPendingTimeout.restart();
|
u2fPendingTimeout.restart();
|
||||||
start();
|
start();
|
||||||
@@ -281,9 +297,19 @@ Scope {
|
|||||||
abort();
|
abort();
|
||||||
|
|
||||||
if (root.u2fPending) {
|
if (root.u2fPending) {
|
||||||
|
if (root.u2fPendingMode === "or") {
|
||||||
|
root.u2fPending = false;
|
||||||
|
root.u2fPendingMode = "";
|
||||||
|
root.u2fState = root.u2fState === "waiting" ? "" : "insert";
|
||||||
|
u2fPendingTimeout.running = false;
|
||||||
|
fprint.checkAvail();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (root.u2fState === "waiting") {
|
if (root.u2fState === "waiting") {
|
||||||
// AND mode: device was found but auth failed → back to password
|
// AND mode: device was found but auth failed → back to password
|
||||||
root.u2fPending = false;
|
root.u2fPending = false;
|
||||||
|
root.u2fPendingMode = "";
|
||||||
root.u2fState = "";
|
root.u2fState = "";
|
||||||
fprint.checkAvail();
|
fprint.checkAvail();
|
||||||
} else {
|
} else {
|
||||||
@@ -292,9 +318,7 @@ Scope {
|
|||||||
u2fErrorRetry.restart();
|
u2fErrorRetry.restart();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// OR mode: prompt to insert key, silently retry
|
|
||||||
root.u2fState = "insert";
|
root.u2fState = "insert";
|
||||||
u2fErrorRetry.restart();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -367,6 +391,7 @@ Scope {
|
|||||||
root.fprintState = "";
|
root.fprintState = "";
|
||||||
root.u2fState = "";
|
root.u2fState = "";
|
||||||
root.u2fPending = false;
|
root.u2fPending = false;
|
||||||
|
root.u2fPendingMode = "";
|
||||||
root.lockMessage = "";
|
root.lockMessage = "";
|
||||||
root.resetAuthFlows();
|
root.resetAuthFlows();
|
||||||
fprint.checkAvail();
|
fprint.checkAvail();
|
||||||
@@ -399,6 +424,7 @@ Scope {
|
|||||||
u2fPendingTimeout.running = false;
|
u2fPendingTimeout.running = false;
|
||||||
unlockRequestTimeout.running = false;
|
unlockRequestTimeout.running = false;
|
||||||
root.u2fPending = false;
|
root.u2fPending = false;
|
||||||
|
root.u2fPendingMode = "";
|
||||||
root.u2fState = "";
|
root.u2fState = "";
|
||||||
u2f.checkAvail();
|
u2f.checkAvail();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user