[gnome-shell/support-choicelist-extension: 40/40] gdmUtil: Enable support for GDM's ChoiceList PAM extension
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/support-choicelist-extension: 40/40] gdmUtil: Enable support for GDM's ChoiceList PAM extension
- Date: Tue, 26 Oct 2021 15:22:00 +0000 (UTC)
commit f38e85aef951e9bbe27fe959fdd32c0d9f864b96
Author: Ray Strode <rstrode redhat com>
Date: Mon Jul 17 16:48:03 2017 -0400
gdmUtil: Enable support for GDM's ChoiceList PAM extension
This commit hooks up support for GDM's ChoiceList PAM extension.
js/gdm/authList.js | 29 +++++++++++-----------
js/gdm/authPrompt.js | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++
js/gdm/loginDialog.js | 5 ++++
js/gdm/util.js | 28 +++++++++++++++++++++
js/ui/unlockDialog.js | 7 ++++++
5 files changed, 123 insertions(+), 15 deletions(-)
---
diff --git a/js/gdm/authList.js b/js/gdm/authList.js
index e4475dc203..c7f44eaa89 100644
--- a/js/gdm/authList.js
+++ b/js/gdm/authList.js
@@ -27,10 +27,10 @@ const AuthListItem = GObject.registerClass({
_init(key, text) {
this.key = key;
const label = new St.Label({
+ text,
style_class: 'auth-list-item-label',
y_align: Clutter.ActorAlign.CENTER,
});
- label.text = text;
super._init({
style_class: 'login-dialog-user-list-item',
@@ -95,13 +95,13 @@ var AuthList = GObject.registerClass({
});
this._scrollView.add_actor(this._box);
- this._items = {};
+ this._items = new Map();
this.connect('key-focus-in', this._moveFocusToItems.bind(this));
}
_moveFocusToItems() {
- let hasItems = Object.keys(this._items).length > 0;
+ let hasItems = this.numItems > 0;
if (!hasItems)
return;
@@ -145,12 +145,10 @@ var AuthList = GObject.registerClass({
}
getItem(key) {
- let item = this._items[key];
-
- if (!item)
+ if (!this._items.has(key))
return null;
- return item;
+ return this._items.get(key);
}
addItem(key, text) {
@@ -159,7 +157,7 @@ var AuthList = GObject.registerClass({
let item = new AuthListItem(key, text);
this._box.add(item, { x_fill: true });
- this._items[key] = item;
+ this._items.set(key, item);
item.connect('activate', this._onItemActivated.bind(this));
@@ -172,22 +170,23 @@ var AuthList = GObject.registerClass({
}
removeItem(key) {
- let item = this._items[key];
-
- if (!item)
+ if (!this._items.has(key))
return;
+ let item = this._items.get(key);
+
item.destroy();
- delete this._items[key];
+
+ this._items.delete(key);
}
- numItems() {
- return Object.keys(this._items).length;
+ get numItems() {
+ return this._items.size;
}
clear() {
this.label.text = '';
this._box.destroy_all_children();
- this._items = {};
+ this._items.clear();
}
});
diff --git a/js/gdm/authPrompt.js b/js/gdm/authPrompt.js
index 4844b9ee0c..092c48f902 100644
--- a/js/gdm/authPrompt.js
+++ b/js/gdm/authPrompt.js
@@ -4,6 +4,7 @@
const { Clutter, GLib, GObject, Pango, Shell, St } = imports.gi;
const Animation = imports.ui.animation;
+const AuthList = imports.gdm.authList;
const Batch = imports.gdm.batch;
const GdmUtil = imports.gdm.util;
const OVirt = imports.gdm.oVirt;
@@ -73,6 +74,7 @@ var AuthPrompt = GObject.registerClass({
this._userVerifier.connect('ask-question', this._onAskQuestion.bind(this));
this._userVerifier.connect('show-message', this._onShowMessage.bind(this));
+ this._userVerifier.connect('show-choice-list', this._onShowChoiceList.bind(this));
this._userVerifier.connect('verification-failed', this._onVerificationFailed.bind(this));
this._userVerifier.connect('verification-complete', this._onVerificationComplete.bind(this));
this._userVerifier.connect('reset', this._onReset.bind(this));
@@ -105,6 +107,27 @@ var AuthPrompt = GObject.registerClass({
capsLockPlaceholder, 'visible',
GObject.BindingFlags.SYNC_CREATE | GObject.BindingFlags.INVERT_BOOLEAN);
+ this._authList = new AuthList.AuthList();
+ this._authList.set({
+ x_expand: true,
+ x_align: Clutter.ActorAlign.START,
+ visible: false,
+ });
+ this._authList.connect('activate', (list, key) => {
+ this._authList.reactive = false;
+ this._authList.ease({
+ opacity: 0,
+ duration: MESSAGE_FADE_OUT_ANIMATION_TIME,
+ mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+ onComplete: () => {
+ this._authList.clear();
+ this._authList.hide();
+ this._userVerifier.selectChoice(this._queryingService, key);
+ },
+ });
+ });
+ this.add_child(this._authList);
+
this._message = new St.Label({
opacity: 0,
styleClass: 'login-dialog-message',
@@ -290,6 +313,20 @@ var AuthPrompt = GObject.registerClass({
this.emit('prompted');
}
+ _onShowChoiceList(userVerifier, serviceName, promptMessage, choiceList) {
+ if (this._queryingService)
+ this.clear();
+
+ this._queryingService = serviceName;
+
+ if (this._preemptiveAnswer)
+ this._preemptiveAnswer = null;
+
+ this.setChoiceList(promptMessage, choiceList);
+ this.updateSensitivity(true);
+ this.emit('prompted');
+ }
+
_onCredentialManagerAuthenticated() {
if (this.verificationStatus != AuthPromptStatus.VERIFICATION_SUCCEEDED)
this.reset();
@@ -425,15 +462,46 @@ var AuthPrompt = GObject.registerClass({
clear() {
this._entry.text = '';
this.stopSpinning();
+ this._authList.clear();
+ this._authList.hide();
}
setQuestion(question) {
this._entry.hint_text = question;
+ this._authList.hide();
this._entry.show();
this._entry.grab_key_focus();
}
+ _fadeInChoiceList() {
+ this._authList.set({
+ opacity: 0,
+ visible: true,
+ reactive: false,
+ });
+ this._authList.ease({
+ opacity: 255,
+ duration: MESSAGE_FADE_OUT_ANIMATION_TIME,
+ transition: Clutter.AnimationMode.EASE_OUT_QUAD,
+ onComplete: () => (this._authList.reactive = true),
+ });
+ }
+
+ setChoiceList(promptMessage, choiceList) {
+ this._authList.clear();
+ this._authList.label.text = promptMessage;
+ for (let key in choiceList) {
+ let text = choiceList[key];
+ this._authList.addItem(key, text);
+ }
+
+ this._entry.hide();
+ if (this._message.text === '')
+ this._message.hide();
+ this._fadeInChoiceList();
+ }
+
getAnswer() {
let text;
@@ -469,6 +537,7 @@ var AuthPrompt = GObject.registerClass({
else
this._message.remove_style_class_name('login-dialog-message-hint');
+ this._message.show();
if (message) {
this._message.remove_all_transitions();
this._message.text = message;
diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js
index d2a82b43d1..41dd996461 100644
--- a/js/gdm/loginDialog.js
+++ b/js/gdm/loginDialog.js
@@ -418,6 +418,11 @@ var LoginDialog = GObject.registerClass({
this._userManager = AccountsService.UserManager.get_default();
this._gdmClient = new Gdm.Client();
+ try {
+ this._gdmClient.set_enabled_extensions([Gdm.UserVerifierChoiceList.interface_info().name]);
+ } catch (e) {
+ }
+
this._settings = new Gio.Settings({ schema_id: GdmUtil.LOGIN_SCREEN_SCHEMA });
this._settings.connect('changed::%s'.format(GdmUtil.BANNER_MESSAGE_KEY),
diff --git a/js/gdm/util.js b/js/gdm/util.js
index 72561daab2..b5f31a2ffc 100644
--- a/js/gdm/util.js
+++ b/js/gdm/util.js
@@ -237,6 +237,10 @@ var ShellUserVerifier = class {
this._disconnectSignals();
this._userVerifier.run_dispose();
this._userVerifier = null;
+ if (this._userVerifierChoiceList) {
+ this._userVerifierChoiceList.run_dispose();
+ this._userVerifierChoiceList = null;
+ }
}
}
@@ -267,6 +271,10 @@ var ShellUserVerifier = class {
}
}
+ selectChoice(serviceName, key) {
+ this._userVerifierChoiceList.call_select_choice(serviceName, key, this._cancellable, null);
+ }
+
answerQuery(serviceName, answer) {
if (!this.hasPendingMessages) {
this._userVerifier.call_answer_query(serviceName, answer, this._cancellable, null);
@@ -453,6 +461,11 @@ var ShellUserVerifier = class {
return;
}
+ if (this._client.get_user_verifier_choice_list)
+ this._userVerifierChoiceList = this._client.get_user_verifier_choice_list();
+ else
+ this._userVerifierChoiceList = null;
+
this.reauthenticating = true;
this._connectSignals();
this._beginVerification();
@@ -471,6 +484,11 @@ var ShellUserVerifier = class {
return;
}
+ if (this._client.get_user_verifier_choice_list)
+ this._userVerifierChoiceList = this._client.get_user_verifier_choice_list();
+ else
+ this._userVerifierChoiceList = null;
+
this._connectSignals();
this._beginVerification();
this._hold.release();
@@ -496,6 +514,9 @@ var ShellUserVerifier = class {
this._signalIds.push(id);
id = this._userVerifier.connect('verification-complete', this._onVerificationComplete.bind(this));
this._signalIds.push(id);
+
+ if (this._userVerifierChoiceList)
+ this._userVerifierChoiceList.connect('choice-query', this._onChoiceListQuery.bind(this));
}
_disconnectSignals() {
@@ -576,6 +597,13 @@ var ShellUserVerifier = class {
this._startService(FINGERPRINT_SERVICE_NAME);
}
+ _onChoiceListQuery(client, serviceName, promptMessage, list) {
+ if (!this.serviceIsForeground(serviceName))
+ return;
+
+ this.emit('show-choice-list', serviceName, promptMessage, list.deep_unpack());
+ }
+
_onInfo(client, serviceName, info) {
if (this.serviceIsForeground(serviceName)) {
this._queueMessage(serviceName, info, MessageType.INFO);
diff --git a/js/ui/unlockDialog.js b/js/ui/unlockDialog.js
index 3ef6aa90f0..2c496e9b99 100644
--- a/js/ui/unlockDialog.js
+++ b/js/ui/unlockDialog.js
@@ -484,6 +484,13 @@ var UnlockDialog = GObject.registerClass({
this._gdmClient = new Gdm.Client();
+ try {
+ this._gdmClient.set_enabled_extensions([
+ Gdm.UserVerifierChoiceList.interface_info().name,
+ ]);
+ } catch (e) {
+ }
+
this._adjustment = new St.Adjustment({
actor: this,
lower: 0,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]