Téléverser les fichiers vers "workstation-setup/src"
This commit is contained in:
@@ -42,13 +42,15 @@ ProvisioningBackend::ProvisioningBackend(QString targetUser, QObject *parent)
|
||||
, m_targetUser(std::move(targetUser))
|
||||
{
|
||||
refreshState();
|
||||
appendLog(QStringLiteral("START currentUser=%1 targetUser=%2 authorized=%3 passwordDone=%4 pinDone=%5 fidoDone=%6")
|
||||
appendLog(QStringLiteral("START currentUser=%1 targetUser=%2 authorized=%3 passwordDone=%4 pinDone=%5 fidoDone=%6 yubiKeyChoice=%7 yubiKeyRequested=%8")
|
||||
.arg(m_currentUser,
|
||||
m_targetUser,
|
||||
authorizedUser() ? QStringLiteral("yes") : QStringLiteral("no"),
|
||||
m_passwordDone ? QStringLiteral("yes") : QStringLiteral("no"),
|
||||
m_pinDone ? QStringLiteral("yes") : QStringLiteral("no"),
|
||||
m_fidoDone ? QStringLiteral("yes") : QStringLiteral("no")));
|
||||
m_fidoDone ? QStringLiteral("yes") : QStringLiteral("no"),
|
||||
yubiKeyChoiceMade() ? QStringLiteral("yes") : QStringLiteral("no"),
|
||||
yubiKeyRequested() ? QStringLiteral("yes") : QStringLiteral("no")));
|
||||
}
|
||||
|
||||
ProvisioningBackend::~ProvisioningBackend()
|
||||
@@ -114,17 +116,35 @@ QString ProvisioningBackend::fidoMarker() const
|
||||
return stateDirectory() + QStringLiteral("/yubikey-fido-enrolled");
|
||||
}
|
||||
|
||||
QString ProvisioningBackend::yubiKeyEnabledMarker() const
|
||||
{
|
||||
return stateDirectory() + QStringLiteral("/yubikey-enabled");
|
||||
}
|
||||
|
||||
QString ProvisioningBackend::yubiKeySkippedMarker() const
|
||||
{
|
||||
return stateDirectory() + QStringLiteral("/yubikey-skipped");
|
||||
}
|
||||
|
||||
void ProvisioningBackend::refreshState()
|
||||
{
|
||||
const bool oldPassword = m_passwordDone;
|
||||
const bool oldPin = m_pinDone;
|
||||
const bool oldFido = m_fidoDone;
|
||||
const bool oldYubiKeyEnabled = m_yubiKeyEnabled;
|
||||
const bool oldYubiKeySkipped = m_yubiKeySkipped;
|
||||
|
||||
m_passwordDone = QFileInfo::exists(passwordMarker());
|
||||
m_pinDone = QFileInfo::exists(pinMarker());
|
||||
m_fidoDone = QFileInfo::exists(fidoMarker());
|
||||
m_yubiKeyEnabled = QFileInfo::exists(yubiKeyEnabledMarker());
|
||||
m_yubiKeySkipped = QFileInfo::exists(yubiKeySkippedMarker());
|
||||
|
||||
if (oldPassword != m_passwordDone || oldPin != m_pinDone || oldFido != m_fidoDone) {
|
||||
if (oldPassword != m_passwordDone
|
||||
|| oldPin != m_pinDone
|
||||
|| oldFido != m_fidoDone
|
||||
|| oldYubiKeyEnabled != m_yubiKeyEnabled
|
||||
|| oldYubiKeySkipped != m_yubiKeySkipped) {
|
||||
emit stateChanged();
|
||||
}
|
||||
}
|
||||
@@ -321,6 +341,38 @@ void ProvisioningBackend::emitResult(Operation operation, bool success, const QS
|
||||
}
|
||||
}
|
||||
|
||||
void ProvisioningBackend::setYubiKeyUsage(bool enabled)
|
||||
{
|
||||
if (!authorizedUser()) {
|
||||
emit yubiKeyChoiceFinished(false, QStringLiteral("Cette opération n'est pas autorisée pour cet utilisateur."));
|
||||
return;
|
||||
}
|
||||
if (m_busy) {
|
||||
emit yubiKeyChoiceFinished(false, QStringLiteral("Une opération de configuration est déjà en cours."));
|
||||
return;
|
||||
}
|
||||
|
||||
// Un compte déjà passé par les étapes YubiKey est considéré comme utilisant
|
||||
// toujours sa clé. Cela assure la compatibilité avec les états v1.9.0.
|
||||
if (!enabled && (m_pinDone || m_fidoDone)) {
|
||||
emit yubiKeyChoiceFinished(false, QStringLiteral("Une YubiKey est déjà configurée pour ce compte."));
|
||||
return;
|
||||
}
|
||||
|
||||
const QString selectedMarker = enabled ? yubiKeyEnabledMarker() : yubiKeySkippedMarker();
|
||||
const QString obsoleteMarker = enabled ? yubiKeySkippedMarker() : yubiKeyEnabledMarker();
|
||||
|
||||
if (!createMarker(selectedMarker)) {
|
||||
emit yubiKeyChoiceFinished(false, QStringLiteral("Impossible d'enregistrer votre choix."));
|
||||
return;
|
||||
}
|
||||
|
||||
QFile::remove(obsoleteMarker);
|
||||
refreshState();
|
||||
appendLog(QStringLiteral("YUBIKEY choice=%1").arg(enabled ? QStringLiteral("enabled") : QStringLiteral("skipped")));
|
||||
emit yubiKeyChoiceFinished(true, QString());
|
||||
}
|
||||
|
||||
void ProvisioningBackend::changePassword(const QString ¤tPassword,
|
||||
const QString &newPassword,
|
||||
const QString &confirmation)
|
||||
@@ -333,6 +385,10 @@ void ProvisioningBackend::changePassword(const QString ¤tPassword,
|
||||
emit passwordChangeFinished(false, QStringLiteral("Une opération de configuration est déjà en cours."));
|
||||
return;
|
||||
}
|
||||
if (!yubiKeyChoiceMade()) {
|
||||
emit passwordChangeFinished(false, QStringLiteral("Indiquez d'abord si vous disposez d'une YubiKey."));
|
||||
return;
|
||||
}
|
||||
if (m_passwordDone) {
|
||||
emit passwordChangeFinished(true, QStringLiteral("Le mot de passe a déjà été personnalisé."));
|
||||
return;
|
||||
@@ -372,6 +428,10 @@ void ProvisioningBackend::initializePin(const QString &newPin,
|
||||
emit pinChangeFinished(false, QStringLiteral("Une opération de configuration est déjà en cours."));
|
||||
return;
|
||||
}
|
||||
if (!yubiKeyRequested()) {
|
||||
emit pinChangeFinished(false, QStringLiteral("Aucune YubiKey n'a été sélectionnée pour ce compte."));
|
||||
return;
|
||||
}
|
||||
if (!m_passwordDone) {
|
||||
emit pinChangeFinished(false, QStringLiteral("Personnalisez d'abord votre mot de passe."));
|
||||
return;
|
||||
@@ -410,6 +470,10 @@ void ProvisioningBackend::enrollFido(const QString ¤tPassword,
|
||||
emit fidoEnrollmentFinished(false, QStringLiteral("Une opération de configuration est déjà en cours."));
|
||||
return;
|
||||
}
|
||||
if (!yubiKeyRequested()) {
|
||||
emit fidoEnrollmentFinished(false, QStringLiteral("Aucune YubiKey n'a été sélectionnée pour ce compte."));
|
||||
return;
|
||||
}
|
||||
if (!m_passwordDone || !m_pinDone) {
|
||||
emit fidoEnrollmentFinished(false, QStringLiteral("Le mot de passe et le code PIN doivent être configurés avant d'associer la YubiKey."));
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user