2012-07-17 18:54:07 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
2013-02-06 19:18:26 +00:00
|
|
|
const Clutter = imports.gi.Clutter;
|
2012-07-17 18:54:07 +00:00
|
|
|
const Gio = imports.gi.Gio;
|
2013-03-18 04:59:56 +00:00
|
|
|
const GLib = imports.gi.GLib;
|
2012-07-17 18:54:07 +00:00
|
|
|
const Lang = imports.lang;
|
2012-08-07 14:49:22 +00:00
|
|
|
const Mainloop = imports.mainloop;
|
2012-07-17 18:54:07 +00:00
|
|
|
const Signals = imports.signals;
|
2013-07-15 21:56:44 +00:00
|
|
|
const St = imports.gi.St;
|
2012-07-17 18:54:07 +00:00
|
|
|
|
|
|
|
const Batch = imports.gdm.batch;
|
|
|
|
const Fprint = imports.gdm.fingerprint;
|
2013-10-10 08:21:47 +00:00
|
|
|
const OVirt = imports.gdm.oVirt;
|
2012-07-17 18:54:07 +00:00
|
|
|
const Main = imports.ui.main;
|
2012-08-03 15:10:45 +00:00
|
|
|
const Params = imports.misc.params;
|
2013-07-18 18:40:10 +00:00
|
|
|
const ShellEntry = imports.ui.shellEntry;
|
2013-06-27 12:54:19 +00:00
|
|
|
const SmartcardManager = imports.misc.smartcardManager;
|
2012-07-17 18:54:07 +00:00
|
|
|
const Tweener = imports.ui.tweener;
|
|
|
|
|
|
|
|
const PASSWORD_SERVICE_NAME = 'gdm-password';
|
|
|
|
const FINGERPRINT_SERVICE_NAME = 'gdm-fingerprint';
|
2013-06-27 12:54:19 +00:00
|
|
|
const SMARTCARD_SERVICE_NAME = 'gdm-smartcard';
|
2013-10-10 08:21:47 +00:00
|
|
|
const OVIRT_SERVICE_NAME = 'gdm-ovirtcred';
|
2017-07-18 17:47:27 +00:00
|
|
|
var FADE_ANIMATION_TIME = 0.16;
|
|
|
|
var CLONE_FADE_ANIMATION_TIME = 0.25;
|
2012-07-17 18:54:07 +00:00
|
|
|
|
|
|
|
const LOGIN_SCREEN_SCHEMA = 'org.gnome.login-screen';
|
2013-07-29 18:18:30 +00:00
|
|
|
const PASSWORD_AUTHENTICATION_KEY = 'enable-password-authentication';
|
2012-07-17 18:54:07 +00:00
|
|
|
const FINGERPRINT_AUTHENTICATION_KEY = 'enable-fingerprint-authentication';
|
2013-06-27 12:54:19 +00:00
|
|
|
const SMARTCARD_AUTHENTICATION_KEY = 'enable-smartcard-authentication';
|
2012-07-17 18:54:07 +00:00
|
|
|
const BANNER_MESSAGE_KEY = 'banner-message-enable';
|
|
|
|
const BANNER_MESSAGE_TEXT_KEY = 'banner-message-text';
|
2012-08-07 14:49:22 +00:00
|
|
|
const ALLOWED_FAILURES_KEY = 'allowed-failures';
|
2012-07-17 18:54:07 +00:00
|
|
|
|
|
|
|
const LOGO_KEY = 'logo';
|
2012-10-30 17:26:30 +00:00
|
|
|
const DISABLE_USER_LIST_KEY = 'disable-user-list';
|
2012-07-17 18:54:07 +00:00
|
|
|
|
2015-03-27 13:36:05 +00:00
|
|
|
// Give user 48ms to read each character of a PAM message
|
2017-07-18 17:47:27 +00:00
|
|
|
var USER_READ_TIME = 48
|
2013-03-18 04:59:56 +00:00
|
|
|
|
2017-07-18 17:47:27 +00:00
|
|
|
var MessageType = {
|
2013-08-19 16:00:33 +00:00
|
|
|
NONE: 0,
|
|
|
|
ERROR: 1,
|
|
|
|
INFO: 2,
|
|
|
|
HINT: 3
|
|
|
|
};
|
|
|
|
|
2012-07-17 18:54:07 +00:00
|
|
|
function fadeInActor(actor) {
|
|
|
|
if (actor.opacity == 255 && actor.visible)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
let hold = new Batch.Hold();
|
|
|
|
actor.show();
|
|
|
|
let [minHeight, naturalHeight] = actor.get_preferred_height(-1);
|
|
|
|
|
|
|
|
actor.opacity = 0;
|
|
|
|
actor.set_height(0);
|
|
|
|
Tweener.addTween(actor,
|
|
|
|
{ opacity: 255,
|
|
|
|
height: naturalHeight,
|
|
|
|
time: FADE_ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad',
|
|
|
|
onComplete: function() {
|
|
|
|
this.set_height(-1);
|
|
|
|
hold.release();
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
return hold;
|
|
|
|
}
|
|
|
|
|
|
|
|
function fadeOutActor(actor) {
|
|
|
|
if (!actor.visible || actor.opacity == 0) {
|
|
|
|
actor.opacity = 0;
|
|
|
|
actor.hide();
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
let hold = new Batch.Hold();
|
|
|
|
Tweener.addTween(actor,
|
|
|
|
{ opacity: 0,
|
|
|
|
height: 0,
|
|
|
|
time: FADE_ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad',
|
|
|
|
onComplete: function() {
|
|
|
|
this.hide();
|
|
|
|
this.set_height(-1);
|
|
|
|
hold.release();
|
|
|
|
},
|
|
|
|
});
|
|
|
|
return hold;
|
|
|
|
}
|
|
|
|
|
2013-02-06 19:18:26 +00:00
|
|
|
function cloneAndFadeOutActor(actor) {
|
|
|
|
// Immediately hide actor so its sibling can have its space
|
|
|
|
// and position, but leave a non-reactive clone on-screen,
|
|
|
|
// so from the user's point of view it smoothly fades away
|
|
|
|
// and reveals its sibling.
|
|
|
|
actor.hide();
|
|
|
|
|
|
|
|
let clone = new Clutter.Clone({ source: actor,
|
|
|
|
reactive: false });
|
|
|
|
|
|
|
|
Main.uiGroup.add_child(clone);
|
|
|
|
|
|
|
|
let [x, y] = actor.get_transformed_position();
|
|
|
|
clone.set_position(x, y);
|
|
|
|
|
|
|
|
let hold = new Batch.Hold();
|
|
|
|
Tweener.addTween(clone,
|
|
|
|
{ opacity: 0,
|
|
|
|
time: CLONE_FADE_ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad',
|
|
|
|
onComplete: function() {
|
|
|
|
clone.destroy();
|
|
|
|
hold.release();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return hold;
|
|
|
|
}
|
|
|
|
|
2017-07-18 17:41:25 +00:00
|
|
|
var ShellUserVerifier = new Lang.Class({
|
2012-07-17 18:54:07 +00:00
|
|
|
Name: 'ShellUserVerifier',
|
|
|
|
|
2012-08-03 15:10:45 +00:00
|
|
|
_init: function(client, params) {
|
|
|
|
params = Params.parse(params, { reauthenticationOnly: false });
|
|
|
|
this._reauthOnly = params.reauthenticationOnly;
|
|
|
|
|
2012-07-17 18:54:07 +00:00
|
|
|
this._client = client;
|
|
|
|
|
2017-06-13 02:24:12 +00:00
|
|
|
this._defaultService = null;
|
|
|
|
this._preemptingService = null;
|
|
|
|
|
2014-06-24 19:17:09 +00:00
|
|
|
this._settings = new Gio.Settings({ schema_id: LOGIN_SCREEN_SCHEMA });
|
2013-07-29 18:18:30 +00:00
|
|
|
this._settings.connect('changed',
|
|
|
|
Lang.bind(this, this._updateDefaultService));
|
util: abstract out default auth service in code
Right now, the primary way a user logs in is with
a password. They can also swipe their finger, if their
fingerprint is enrolled, but it's expected the fingerprint
auth service won't ask questions the user has to respond to
by typing. As such, we ignore questions that comes from
anything but the main auth service: gdm-password.
In the future, if a user inserts a smartcard, we'll want
to treat the gdm-smartcard service as the main auth service,
and let any questions from it get to the user.
This commit tries to prepare for that eventuality by storing
the name of the default auth service away in a _defaultService variable
before verification has begun, and then later checking incoming
queries against that service instead of checking against
string 'gdm-password' directly.
Of course, right now, _defaultService is always gdm-password.
https://bugzilla.gnome.org/show_bug.cgi?id=683437
2013-07-28 23:42:26 +00:00
|
|
|
this._updateDefaultService();
|
2012-07-17 18:54:07 +00:00
|
|
|
|
2017-03-14 20:02:51 +00:00
|
|
|
this._fprintManager = Fprint.FprintManager();
|
2013-06-27 12:54:19 +00:00
|
|
|
this._smartcardManager = SmartcardManager.getSmartcardManager();
|
|
|
|
|
|
|
|
// We check for smartcards right away, since an inserted smartcard
|
|
|
|
// at startup should result in immediately initiating authentication.
|
2017-06-26 18:47:19 +00:00
|
|
|
// This is different than fingerprint readers, where we only check them
|
2013-06-27 12:54:19 +00:00
|
|
|
// after a user has been picked.
|
2017-06-13 02:24:12 +00:00
|
|
|
this.smartcardDetected = false;
|
2013-06-27 12:54:19 +00:00
|
|
|
this._checkForSmartcard();
|
|
|
|
|
2014-10-09 18:10:12 +00:00
|
|
|
this._smartcardInsertedId = this._smartcardManager.connect('smartcard-inserted',
|
|
|
|
Lang.bind(this, this._checkForSmartcard));
|
|
|
|
this._smartcardRemovedId = this._smartcardManager.connect('smartcard-removed',
|
|
|
|
Lang.bind(this, this._checkForSmartcard));
|
2013-06-27 12:54:19 +00:00
|
|
|
|
2013-03-18 04:59:56 +00:00
|
|
|
this._messageQueue = [];
|
|
|
|
this._messageQueueTimeoutId = 0;
|
|
|
|
this.hasPendingMessages = false;
|
2013-07-22 14:59:57 +00:00
|
|
|
this.reauthenticating = false;
|
2012-08-07 14:49:22 +00:00
|
|
|
|
|
|
|
this._failCounter = 0;
|
2013-10-10 08:21:47 +00:00
|
|
|
|
|
|
|
this._oVirtCredentialsManager = OVirt.getOVirtCredentialsManager();
|
|
|
|
|
|
|
|
if (this._oVirtCredentialsManager.hasToken())
|
|
|
|
this._oVirtUserAuthenticated(this._oVirtCredentialsManager.getToken());
|
|
|
|
|
2014-10-09 18:10:12 +00:00
|
|
|
this._oVirtUserAuthenticatedId = this._oVirtCredentialsManager.connect('user-authenticated',
|
|
|
|
Lang.bind(this, this._oVirtUserAuthenticated));
|
2012-07-17 18:54:07 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
begin: function(userName, hold) {
|
2012-08-26 12:54:02 +00:00
|
|
|
this._cancellable = new Gio.Cancellable();
|
2012-07-17 18:54:07 +00:00
|
|
|
this._hold = hold;
|
|
|
|
this._userName = userName;
|
2013-07-22 14:59:57 +00:00
|
|
|
this.reauthenticating = false;
|
2012-07-17 18:54:07 +00:00
|
|
|
|
2012-08-26 12:54:02 +00:00
|
|
|
this._checkForFingerprintReader();
|
|
|
|
|
2012-07-17 18:54:07 +00:00
|
|
|
if (userName) {
|
|
|
|
// If possible, reauthenticate an already running session,
|
|
|
|
// so any session specific credentials get updated appropriately
|
|
|
|
this._client.open_reauthentication_channel(userName, this._cancellable,
|
|
|
|
Lang.bind(this, this._reauthenticationChannelOpened));
|
|
|
|
} else {
|
|
|
|
this._client.get_user_verifier(this._cancellable, Lang.bind(this, this._userVerifierGot));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
cancel: function() {
|
2012-08-26 12:54:02 +00:00
|
|
|
if (this._cancellable)
|
|
|
|
this._cancellable.cancel();
|
2012-07-17 18:54:07 +00:00
|
|
|
|
2013-07-29 14:52:02 +00:00
|
|
|
if (this._userVerifier) {
|
2012-07-17 18:54:07 +00:00
|
|
|
this._userVerifier.call_cancel_sync(null);
|
2013-07-29 14:52:02 +00:00
|
|
|
this.clear();
|
|
|
|
}
|
2012-07-17 18:54:07 +00:00
|
|
|
},
|
|
|
|
|
2014-10-09 18:10:12 +00:00
|
|
|
_clearUserVerifier: function() {
|
|
|
|
if (this._userVerifier) {
|
|
|
|
this._userVerifier.run_dispose();
|
|
|
|
this._userVerifier = null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-07-17 18:54:07 +00:00
|
|
|
clear: function() {
|
2012-08-26 12:54:02 +00:00
|
|
|
if (this._cancellable) {
|
|
|
|
this._cancellable.cancel();
|
|
|
|
this._cancellable = null;
|
|
|
|
}
|
2012-07-17 18:54:07 +00:00
|
|
|
|
2014-10-09 18:10:12 +00:00
|
|
|
this._clearUserVerifier();
|
2013-03-18 04:59:56 +00:00
|
|
|
this._clearMessageQueue();
|
2012-07-17 18:54:07 +00:00
|
|
|
},
|
|
|
|
|
2014-10-09 18:10:12 +00:00
|
|
|
destroy: function() {
|
|
|
|
this.clear();
|
|
|
|
|
|
|
|
this._settings.run_dispose();
|
|
|
|
this._settings = null;
|
|
|
|
|
|
|
|
this._smartcardManager.disconnect(this._smartcardInsertedId);
|
|
|
|
this._smartcardManager.disconnect(this._smartcardRemovedId);
|
|
|
|
this._smartcardManager = null;
|
|
|
|
|
|
|
|
this._oVirtCredentialsManager.disconnect(this._oVirtUserAuthenticatedId);
|
|
|
|
this._oVirtCredentialsManager = null;
|
|
|
|
},
|
|
|
|
|
2012-07-17 18:54:07 +00:00
|
|
|
answerQuery: function(serviceName, answer) {
|
2013-07-16 19:48:27 +00:00
|
|
|
if (!this.hasPendingMessages) {
|
2013-03-18 04:59:56 +00:00
|
|
|
this._userVerifier.call_answer_query(serviceName, answer, this._cancellable, null);
|
|
|
|
} else {
|
2013-07-17 17:06:10 +00:00
|
|
|
let signalId = this.connect('no-more-messages',
|
|
|
|
Lang.bind(this, function() {
|
|
|
|
this.disconnect(signalId);
|
|
|
|
this._userVerifier.call_answer_query(serviceName, answer, this._cancellable, null);
|
|
|
|
}));
|
2013-03-18 04:59:56 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_getIntervalForMessage: function(message) {
|
|
|
|
// We probably could be smarter here
|
|
|
|
return message.length * USER_READ_TIME;
|
|
|
|
},
|
|
|
|
|
|
|
|
finishMessageQueue: function() {
|
|
|
|
if (!this.hasPendingMessages)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._messageQueue = [];
|
2012-10-29 16:39:00 +00:00
|
|
|
|
2013-03-18 04:59:56 +00:00
|
|
|
this.hasPendingMessages = false;
|
|
|
|
this.emit('no-more-messages');
|
|
|
|
},
|
|
|
|
|
|
|
|
_queueMessageTimeout: function() {
|
|
|
|
if (this._messageQueue.length == 0) {
|
|
|
|
this.finishMessageQueue();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this._messageQueueTimeoutId != 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let message = this._messageQueue.shift();
|
2013-08-19 16:00:33 +00:00
|
|
|
|
|
|
|
this.emit('show-message', message.text, message.type);
|
2013-03-18 04:59:56 +00:00
|
|
|
|
|
|
|
this._messageQueueTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
|
|
|
|
message.interval,
|
|
|
|
Lang.bind(this, function() {
|
|
|
|
this._messageQueueTimeoutId = 0;
|
|
|
|
this._queueMessageTimeout();
|
2013-11-29 00:45:39 +00:00
|
|
|
return GLib.SOURCE_REMOVE;
|
2013-03-18 04:59:56 +00:00
|
|
|
}));
|
2014-04-10 17:26:52 +00:00
|
|
|
GLib.Source.set_name_by_id(this._messageQueueTimeoutId, '[gnome-shell] this._queueMessageTimeout');
|
2013-03-18 04:59:56 +00:00
|
|
|
},
|
|
|
|
|
2013-08-19 16:00:33 +00:00
|
|
|
_queueMessage: function(message, messageType) {
|
2013-03-18 04:59:56 +00:00
|
|
|
let interval = this._getIntervalForMessage(message);
|
|
|
|
|
|
|
|
this.hasPendingMessages = true;
|
2013-08-19 16:00:33 +00:00
|
|
|
this._messageQueue.push({ text: message, type: messageType, interval: interval });
|
2013-03-18 04:59:56 +00:00
|
|
|
this._queueMessageTimeout();
|
|
|
|
},
|
|
|
|
|
|
|
|
_clearMessageQueue: function() {
|
|
|
|
this.finishMessageQueue();
|
|
|
|
|
|
|
|
if (this._messageQueueTimeoutId != 0) {
|
|
|
|
GLib.source_remove(this._messageQueueTimeoutId);
|
|
|
|
this._messageQueueTimeoutId = 0;
|
|
|
|
}
|
2013-08-19 16:00:33 +00:00
|
|
|
this.emit('show-message', null, MessageType.NONE);
|
2012-07-17 18:54:07 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_checkForFingerprintReader: function() {
|
|
|
|
this._haveFingerprintReader = false;
|
|
|
|
|
2017-03-14 20:02:51 +00:00
|
|
|
if (!this._settings.get_boolean(FINGERPRINT_AUTHENTICATION_KEY) ||
|
|
|
|
this._fprintManager == null) {
|
2013-07-29 18:18:30 +00:00
|
|
|
this._updateDefaultService();
|
2012-07-17 18:54:07 +00:00
|
|
|
return;
|
2013-07-29 18:18:30 +00:00
|
|
|
}
|
2012-07-17 18:54:07 +00:00
|
|
|
|
|
|
|
this._fprintManager.GetDefaultDeviceRemote(Gio.DBusCallFlags.NONE, this._cancellable, Lang.bind(this,
|
|
|
|
function(device, error) {
|
2014-10-09 18:25:48 +00:00
|
|
|
if (!error && device) {
|
2012-07-17 18:54:07 +00:00
|
|
|
this._haveFingerprintReader = true;
|
2013-07-29 18:18:30 +00:00
|
|
|
this._updateDefaultService();
|
2014-10-09 18:25:48 +00:00
|
|
|
}
|
2012-07-17 18:54:07 +00:00
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
2013-10-10 08:21:47 +00:00
|
|
|
_oVirtUserAuthenticated: function(token) {
|
|
|
|
this._preemptingService = OVIRT_SERVICE_NAME;
|
|
|
|
this.emit('ovirt-user-authenticated');
|
|
|
|
},
|
|
|
|
|
2013-06-27 12:54:19 +00:00
|
|
|
_checkForSmartcard: function() {
|
|
|
|
let smartcardDetected;
|
|
|
|
|
|
|
|
if (!this._settings.get_boolean(SMARTCARD_AUTHENTICATION_KEY))
|
|
|
|
smartcardDetected = false;
|
2014-03-13 17:47:50 +00:00
|
|
|
else if (this._reauthOnly)
|
2013-06-27 12:54:19 +00:00
|
|
|
smartcardDetected = this._smartcardManager.hasInsertedLoginToken();
|
|
|
|
else
|
|
|
|
smartcardDetected = this._smartcardManager.hasInsertedTokens();
|
|
|
|
|
|
|
|
if (smartcardDetected != this.smartcardDetected) {
|
|
|
|
this.smartcardDetected = smartcardDetected;
|
|
|
|
|
|
|
|
if (this.smartcardDetected)
|
|
|
|
this._preemptingService = SMARTCARD_SERVICE_NAME;
|
|
|
|
else if (this._preemptingService == SMARTCARD_SERVICE_NAME)
|
|
|
|
this._preemptingService = null;
|
|
|
|
|
|
|
|
this.emit('smartcard-status-changed');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-09-06 14:40:13 +00:00
|
|
|
_reportInitError: function(where, error) {
|
|
|
|
logError(error, where);
|
2012-10-03 19:25:49 +00:00
|
|
|
this._hold.release();
|
2012-09-06 14:40:13 +00:00
|
|
|
|
2013-08-19 16:00:33 +00:00
|
|
|
this._queueMessage(_("Authentication error"), MessageType.ERROR);
|
2012-09-06 14:40:13 +00:00
|
|
|
this._verificationFailed(false);
|
|
|
|
},
|
|
|
|
|
2012-07-17 18:54:07 +00:00
|
|
|
_reauthenticationChannelOpened: function(client, result) {
|
|
|
|
try {
|
2014-10-09 18:10:12 +00:00
|
|
|
this._clearUserVerifier();
|
2012-07-17 18:54:07 +00:00
|
|
|
this._userVerifier = client.open_reauthentication_channel_finish(result);
|
2012-09-06 14:40:13 +00:00
|
|
|
} catch(e if e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) {
|
|
|
|
return;
|
|
|
|
} catch(e if e.matches(Gio.DBusError, Gio.DBusError.ACCESS_DENIED) &&
|
|
|
|
!this._reauthOnly) {
|
|
|
|
// Gdm emits org.freedesktop.DBus.Error.AccessDenied when there is
|
|
|
|
// no session to reauthenticate. Fall back to performing verification
|
|
|
|
// from this login session
|
2012-07-17 18:54:07 +00:00
|
|
|
client.get_user_verifier(this._cancellable, Lang.bind(this, this._userVerifierGot));
|
2012-09-06 14:40:13 +00:00
|
|
|
return;
|
|
|
|
} catch(e) {
|
|
|
|
this._reportInitError('Failed to open reauthentication channel', e);
|
|
|
|
return;
|
2012-07-17 18:54:07 +00:00
|
|
|
}
|
2012-09-06 14:40:13 +00:00
|
|
|
|
2013-07-22 14:59:57 +00:00
|
|
|
this.reauthenticating = true;
|
2012-09-06 14:40:13 +00:00
|
|
|
this._connectSignals();
|
|
|
|
this._beginVerification();
|
|
|
|
this._hold.release();
|
2012-07-17 18:54:07 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_userVerifierGot: function(client, result) {
|
2012-08-26 12:54:02 +00:00
|
|
|
try {
|
2014-10-09 18:10:12 +00:00
|
|
|
this._clearUserVerifier();
|
2012-08-26 12:54:02 +00:00
|
|
|
this._userVerifier = client.get_user_verifier_finish(result);
|
2012-09-06 14:40:13 +00:00
|
|
|
} catch(e if e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) {
|
|
|
|
return;
|
|
|
|
} catch(e) {
|
|
|
|
this._reportInitError('Failed to obtain user verifier', e);
|
2012-08-26 12:54:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-17 18:54:07 +00:00
|
|
|
this._connectSignals();
|
|
|
|
this._beginVerification();
|
|
|
|
this._hold.release();
|
|
|
|
},
|
|
|
|
|
|
|
|
_connectSignals: function() {
|
|
|
|
this._userVerifier.connect('info', Lang.bind(this, this._onInfo));
|
|
|
|
this._userVerifier.connect('problem', Lang.bind(this, this._onProblem));
|
|
|
|
this._userVerifier.connect('info-query', Lang.bind(this, this._onInfoQuery));
|
|
|
|
this._userVerifier.connect('secret-info-query', Lang.bind(this, this._onSecretInfoQuery));
|
|
|
|
this._userVerifier.connect('conversation-stopped', Lang.bind(this, this._onConversationStopped));
|
|
|
|
this._userVerifier.connect('reset', Lang.bind(this, this._onReset));
|
|
|
|
this._userVerifier.connect('verification-complete', Lang.bind(this, this._onVerificationComplete));
|
|
|
|
},
|
|
|
|
|
util: abstract out default auth service in code
Right now, the primary way a user logs in is with
a password. They can also swipe their finger, if their
fingerprint is enrolled, but it's expected the fingerprint
auth service won't ask questions the user has to respond to
by typing. As such, we ignore questions that comes from
anything but the main auth service: gdm-password.
In the future, if a user inserts a smartcard, we'll want
to treat the gdm-smartcard service as the main auth service,
and let any questions from it get to the user.
This commit tries to prepare for that eventuality by storing
the name of the default auth service away in a _defaultService variable
before verification has begun, and then later checking incoming
queries against that service instead of checking against
string 'gdm-password' directly.
Of course, right now, _defaultService is always gdm-password.
https://bugzilla.gnome.org/show_bug.cgi?id=683437
2013-07-28 23:42:26 +00:00
|
|
|
_getForegroundService: function() {
|
2013-06-27 12:54:19 +00:00
|
|
|
if (this._preemptingService)
|
|
|
|
return this._preemptingService;
|
|
|
|
|
util: abstract out default auth service in code
Right now, the primary way a user logs in is with
a password. They can also swipe their finger, if their
fingerprint is enrolled, but it's expected the fingerprint
auth service won't ask questions the user has to respond to
by typing. As such, we ignore questions that comes from
anything but the main auth service: gdm-password.
In the future, if a user inserts a smartcard, we'll want
to treat the gdm-smartcard service as the main auth service,
and let any questions from it get to the user.
This commit tries to prepare for that eventuality by storing
the name of the default auth service away in a _defaultService variable
before verification has begun, and then later checking incoming
queries against that service instead of checking against
string 'gdm-password' directly.
Of course, right now, _defaultService is always gdm-password.
https://bugzilla.gnome.org/show_bug.cgi?id=683437
2013-07-28 23:42:26 +00:00
|
|
|
return this._defaultService;
|
|
|
|
},
|
|
|
|
|
|
|
|
serviceIsForeground: function(serviceName) {
|
|
|
|
return serviceName == this._getForegroundService();
|
|
|
|
},
|
|
|
|
|
2013-06-27 12:54:19 +00:00
|
|
|
serviceIsDefault: function(serviceName) {
|
|
|
|
return serviceName == this._defaultService;
|
|
|
|
},
|
|
|
|
|
util: abstract out default auth service in code
Right now, the primary way a user logs in is with
a password. They can also swipe their finger, if their
fingerprint is enrolled, but it's expected the fingerprint
auth service won't ask questions the user has to respond to
by typing. As such, we ignore questions that comes from
anything but the main auth service: gdm-password.
In the future, if a user inserts a smartcard, we'll want
to treat the gdm-smartcard service as the main auth service,
and let any questions from it get to the user.
This commit tries to prepare for that eventuality by storing
the name of the default auth service away in a _defaultService variable
before verification has begun, and then later checking incoming
queries against that service instead of checking against
string 'gdm-password' directly.
Of course, right now, _defaultService is always gdm-password.
https://bugzilla.gnome.org/show_bug.cgi?id=683437
2013-07-28 23:42:26 +00:00
|
|
|
_updateDefaultService: function() {
|
2013-07-29 18:18:30 +00:00
|
|
|
if (this._settings.get_boolean(PASSWORD_AUTHENTICATION_KEY))
|
|
|
|
this._defaultService = PASSWORD_SERVICE_NAME;
|
2014-11-14 20:57:16 +00:00
|
|
|
else if (this._settings.get_boolean(SMARTCARD_AUTHENTICATION_KEY))
|
2013-06-27 12:54:19 +00:00
|
|
|
this._defaultService = SMARTCARD_SERVICE_NAME;
|
2013-07-29 18:18:30 +00:00
|
|
|
else if (this._haveFingerprintReader)
|
|
|
|
this._defaultService = FINGERPRINT_SERVICE_NAME;
|
util: abstract out default auth service in code
Right now, the primary way a user logs in is with
a password. They can also swipe their finger, if their
fingerprint is enrolled, but it's expected the fingerprint
auth service won't ask questions the user has to respond to
by typing. As such, we ignore questions that comes from
anything but the main auth service: gdm-password.
In the future, if a user inserts a smartcard, we'll want
to treat the gdm-smartcard service as the main auth service,
and let any questions from it get to the user.
This commit tries to prepare for that eventuality by storing
the name of the default auth service away in a _defaultService variable
before verification has begun, and then later checking incoming
queries against that service instead of checking against
string 'gdm-password' directly.
Of course, right now, _defaultService is always gdm-password.
https://bugzilla.gnome.org/show_bug.cgi?id=683437
2013-07-28 23:42:26 +00:00
|
|
|
},
|
|
|
|
|
2013-08-16 14:29:26 +00:00
|
|
|
_startService: function(serviceName) {
|
2012-07-17 18:54:07 +00:00
|
|
|
this._hold.acquire();
|
2013-08-21 22:05:55 +00:00
|
|
|
if (this._userName) {
|
|
|
|
this._userVerifier.call_begin_verification_for_user(serviceName,
|
|
|
|
this._userName,
|
|
|
|
this._cancellable,
|
|
|
|
Lang.bind(this, function(obj, result) {
|
|
|
|
try {
|
|
|
|
obj.call_begin_verification_for_user_finish(result);
|
|
|
|
} catch(e if e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) {
|
|
|
|
return;
|
|
|
|
} catch(e) {
|
|
|
|
this._reportInitError('Failed to start verification for user', e);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._hold.release();
|
|
|
|
}));
|
|
|
|
} else {
|
|
|
|
this._userVerifier.call_begin_verification(serviceName,
|
|
|
|
this._cancellable,
|
|
|
|
Lang.bind(this, function(obj, result) {
|
|
|
|
try {
|
|
|
|
obj.call_begin_verification_finish(result);
|
|
|
|
} catch(e if e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) {
|
|
|
|
return;
|
|
|
|
} catch(e) {
|
|
|
|
this._reportInitError('Failed to start verification', e);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._hold.release();
|
|
|
|
}));
|
|
|
|
}
|
2013-08-16 14:29:26 +00:00
|
|
|
},
|
2012-07-17 18:54:07 +00:00
|
|
|
|
2013-08-16 14:29:26 +00:00
|
|
|
_beginVerification: function() {
|
|
|
|
this._startService(this._getForegroundService());
|
|
|
|
|
2013-07-29 18:18:30 +00:00
|
|
|
if (this._userName && this._haveFingerprintReader && !this.serviceIsForeground(FINGERPRINT_SERVICE_NAME))
|
2013-08-16 14:29:26 +00:00
|
|
|
this._startService(FINGERPRINT_SERVICE_NAME);
|
2012-07-17 18:54:07 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_onInfo: function(client, serviceName, info) {
|
2013-07-29 18:23:45 +00:00
|
|
|
if (this.serviceIsForeground(serviceName)) {
|
2013-08-19 16:00:33 +00:00
|
|
|
this._queueMessage(info, MessageType.INFO);
|
2013-07-29 18:23:45 +00:00
|
|
|
} else if (serviceName == FINGERPRINT_SERVICE_NAME &&
|
2012-07-17 18:54:07 +00:00
|
|
|
this._haveFingerprintReader) {
|
2013-07-29 18:23:45 +00:00
|
|
|
// We don't show fingerprint messages directly since it's
|
|
|
|
// not the main auth service. Instead we use the messages
|
|
|
|
// as a cue to display our own message.
|
2012-08-20 00:15:18 +00:00
|
|
|
|
|
|
|
// Translators: this message is shown below the password entry field
|
|
|
|
// to indicate the user can swipe their finger instead
|
2013-08-19 16:00:33 +00:00
|
|
|
this._queueMessage(_("(or swipe finger)"), MessageType.HINT);
|
2012-07-17 18:54:07 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_onProblem: function(client, serviceName, problem) {
|
util: abstract out default auth service in code
Right now, the primary way a user logs in is with
a password. They can also swipe their finger, if their
fingerprint is enrolled, but it's expected the fingerprint
auth service won't ask questions the user has to respond to
by typing. As such, we ignore questions that comes from
anything but the main auth service: gdm-password.
In the future, if a user inserts a smartcard, we'll want
to treat the gdm-smartcard service as the main auth service,
and let any questions from it get to the user.
This commit tries to prepare for that eventuality by storing
the name of the default auth service away in a _defaultService variable
before verification has begun, and then later checking incoming
queries against that service instead of checking against
string 'gdm-password' directly.
Of course, right now, _defaultService is always gdm-password.
https://bugzilla.gnome.org/show_bug.cgi?id=683437
2013-07-28 23:42:26 +00:00
|
|
|
if (!this.serviceIsForeground(serviceName))
|
2012-07-17 18:54:07 +00:00
|
|
|
return;
|
util: abstract out default auth service in code
Right now, the primary way a user logs in is with
a password. They can also swipe their finger, if their
fingerprint is enrolled, but it's expected the fingerprint
auth service won't ask questions the user has to respond to
by typing. As such, we ignore questions that comes from
anything but the main auth service: gdm-password.
In the future, if a user inserts a smartcard, we'll want
to treat the gdm-smartcard service as the main auth service,
and let any questions from it get to the user.
This commit tries to prepare for that eventuality by storing
the name of the default auth service away in a _defaultService variable
before verification has begun, and then later checking incoming
queries against that service instead of checking against
string 'gdm-password' directly.
Of course, right now, _defaultService is always gdm-password.
https://bugzilla.gnome.org/show_bug.cgi?id=683437
2013-07-28 23:42:26 +00:00
|
|
|
|
2013-08-19 16:00:33 +00:00
|
|
|
this._queueMessage(problem, MessageType.ERROR);
|
2012-07-17 18:54:07 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_onInfoQuery: function(client, serviceName, question) {
|
util: abstract out default auth service in code
Right now, the primary way a user logs in is with
a password. They can also swipe their finger, if their
fingerprint is enrolled, but it's expected the fingerprint
auth service won't ask questions the user has to respond to
by typing. As such, we ignore questions that comes from
anything but the main auth service: gdm-password.
In the future, if a user inserts a smartcard, we'll want
to treat the gdm-smartcard service as the main auth service,
and let any questions from it get to the user.
This commit tries to prepare for that eventuality by storing
the name of the default auth service away in a _defaultService variable
before verification has begun, and then later checking incoming
queries against that service instead of checking against
string 'gdm-password' directly.
Of course, right now, _defaultService is always gdm-password.
https://bugzilla.gnome.org/show_bug.cgi?id=683437
2013-07-28 23:42:26 +00:00
|
|
|
if (!this.serviceIsForeground(serviceName))
|
2012-07-17 18:54:07 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
this.emit('ask-question', serviceName, question, '');
|
|
|
|
},
|
|
|
|
|
|
|
|
_onSecretInfoQuery: function(client, serviceName, secretQuestion) {
|
util: abstract out default auth service in code
Right now, the primary way a user logs in is with
a password. They can also swipe their finger, if their
fingerprint is enrolled, but it's expected the fingerprint
auth service won't ask questions the user has to respond to
by typing. As such, we ignore questions that comes from
anything but the main auth service: gdm-password.
In the future, if a user inserts a smartcard, we'll want
to treat the gdm-smartcard service as the main auth service,
and let any questions from it get to the user.
This commit tries to prepare for that eventuality by storing
the name of the default auth service away in a _defaultService variable
before verification has begun, and then later checking incoming
queries against that service instead of checking against
string 'gdm-password' directly.
Of course, right now, _defaultService is always gdm-password.
https://bugzilla.gnome.org/show_bug.cgi?id=683437
2013-07-28 23:42:26 +00:00
|
|
|
if (!this.serviceIsForeground(serviceName))
|
2012-07-17 18:54:07 +00:00
|
|
|
return;
|
|
|
|
|
2013-10-10 08:21:47 +00:00
|
|
|
if (serviceName == OVIRT_SERVICE_NAME) {
|
|
|
|
// The only question asked by this service is "Token?"
|
|
|
|
this.answerQuery(serviceName, this._oVirtCredentialsManager.getToken());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-17 18:54:07 +00:00
|
|
|
this.emit('ask-question', serviceName, secretQuestion, '\u25cf');
|
|
|
|
},
|
|
|
|
|
|
|
|
_onReset: function() {
|
2012-08-07 14:49:22 +00:00
|
|
|
// Clear previous attempts to authenticate
|
|
|
|
this._failCounter = 0;
|
util: abstract out default auth service in code
Right now, the primary way a user logs in is with
a password. They can also swipe their finger, if their
fingerprint is enrolled, but it's expected the fingerprint
auth service won't ask questions the user has to respond to
by typing. As such, we ignore questions that comes from
anything but the main auth service: gdm-password.
In the future, if a user inserts a smartcard, we'll want
to treat the gdm-smartcard service as the main auth service,
and let any questions from it get to the user.
This commit tries to prepare for that eventuality by storing
the name of the default auth service away in a _defaultService variable
before verification has begun, and then later checking incoming
queries against that service instead of checking against
string 'gdm-password' directly.
Of course, right now, _defaultService is always gdm-password.
https://bugzilla.gnome.org/show_bug.cgi?id=683437
2013-07-28 23:42:26 +00:00
|
|
|
this._updateDefaultService();
|
2012-07-17 18:54:07 +00:00
|
|
|
|
|
|
|
this.emit('reset');
|
|
|
|
},
|
|
|
|
|
|
|
|
_onVerificationComplete: function() {
|
|
|
|
this.emit('verification-complete');
|
|
|
|
},
|
|
|
|
|
2013-03-18 04:59:56 +00:00
|
|
|
_cancelAndReset: function() {
|
|
|
|
this.cancel();
|
|
|
|
this._onReset();
|
|
|
|
},
|
|
|
|
|
|
|
|
_retry: function() {
|
|
|
|
this.begin(this._userName, new Batch.Hold());
|
|
|
|
},
|
|
|
|
|
2012-09-06 14:40:13 +00:00
|
|
|
_verificationFailed: function(retry) {
|
2012-08-07 14:49:22 +00:00
|
|
|
// For Not Listed / enterprise logins, immediately reset
|
|
|
|
// the dialog
|
|
|
|
// Otherwise, we allow ALLOWED_FAILURES attempts. After that, we
|
|
|
|
// go back to the welcome screen.
|
|
|
|
|
2012-10-29 16:40:55 +00:00
|
|
|
this._failCounter++;
|
2012-09-06 14:40:13 +00:00
|
|
|
let canRetry = retry && this._userName &&
|
|
|
|
this._failCounter < this._settings.get_int(ALLOWED_FAILURES_KEY);
|
|
|
|
|
|
|
|
if (canRetry) {
|
2013-07-16 19:48:27 +00:00
|
|
|
if (!this.hasPendingMessages) {
|
2013-03-18 04:59:56 +00:00
|
|
|
this._retry();
|
|
|
|
} else {
|
2013-07-17 17:06:10 +00:00
|
|
|
let signalId = this.connect('no-more-messages',
|
|
|
|
Lang.bind(this, function() {
|
|
|
|
this.disconnect(signalId);
|
2017-06-07 19:00:11 +00:00
|
|
|
if (this._cancellable && !this._cancellable.is_cancelled())
|
|
|
|
this._retry();
|
2013-07-17 17:06:10 +00:00
|
|
|
}));
|
2013-03-18 04:59:56 +00:00
|
|
|
}
|
2012-09-06 14:40:13 +00:00
|
|
|
} else {
|
2013-07-16 19:48:27 +00:00
|
|
|
if (!this.hasPendingMessages) {
|
2013-03-18 04:59:56 +00:00
|
|
|
this._cancelAndReset();
|
|
|
|
} else {
|
2013-07-17 17:06:10 +00:00
|
|
|
let signalId = this.connect('no-more-messages',
|
|
|
|
Lang.bind(this, function() {
|
|
|
|
this.disconnect(signalId);
|
|
|
|
this._cancelAndReset();
|
|
|
|
}));
|
2013-03-18 04:59:56 +00:00
|
|
|
}
|
2012-08-07 14:49:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.emit('verification-failed');
|
|
|
|
},
|
|
|
|
|
2012-07-17 18:54:07 +00:00
|
|
|
_onConversationStopped: function(client, serviceName) {
|
2013-10-10 08:21:47 +00:00
|
|
|
// If the login failed with the preauthenticated oVirt credentials
|
|
|
|
// then discard the credentials and revert to default authentication
|
|
|
|
// mechanism.
|
|
|
|
if (this.serviceIsForeground(OVIRT_SERVICE_NAME)) {
|
|
|
|
this._oVirtCredentialsManager.resetToken();
|
|
|
|
this._preemptingService = null;
|
|
|
|
this._verificationFailed(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-17 18:54:07 +00:00
|
|
|
// if the password service fails, then cancel everything.
|
|
|
|
// But if, e.g., fingerprint fails, still give
|
|
|
|
// password authentication a chance to succeed
|
util: abstract out default auth service in code
Right now, the primary way a user logs in is with
a password. They can also swipe their finger, if their
fingerprint is enrolled, but it's expected the fingerprint
auth service won't ask questions the user has to respond to
by typing. As such, we ignore questions that comes from
anything but the main auth service: gdm-password.
In the future, if a user inserts a smartcard, we'll want
to treat the gdm-smartcard service as the main auth service,
and let any questions from it get to the user.
This commit tries to prepare for that eventuality by storing
the name of the default auth service away in a _defaultService variable
before verification has begun, and then later checking incoming
queries against that service instead of checking against
string 'gdm-password' directly.
Of course, right now, _defaultService is always gdm-password.
https://bugzilla.gnome.org/show_bug.cgi?id=683437
2013-07-28 23:42:26 +00:00
|
|
|
if (this.serviceIsForeground(serviceName)) {
|
2012-09-06 14:40:13 +00:00
|
|
|
this._verificationFailed(true);
|
2012-08-20 01:37:54 +00:00
|
|
|
}
|
2012-07-17 18:54:07 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
Signals.addSignalMethods(ShellUserVerifier.prototype);
|