diff --git a/src/modules/users/UsersPage.cpp b/src/modules/users/UsersPage.cpp
index 62292b76c..82568f81a 100644
--- a/src/modules/users/UsersPage.cpp
+++ b/src/modules/users/UsersPage.cpp
@@ -88,6 +88,13 @@ UsersPage::UsersPage( QWidget* parent )
this, &UsersPage::onRootPasswordTextChanged );
connect( ui->textBoxVerifiedRootPassword, &QLineEdit::textChanged,
this, &UsersPage::onRootPasswordTextChanged );
+ connect( ui->checkBoxValidatePassword, &QCheckBox::stateChanged,
+ this, [this]( int checked )
+ {
+ onPasswordTextChanged( ui->textBoxUserPassword->text() );
+ onRootPasswordTextChanged( ui->textBoxRootPassword->text() );
+ checkReady( isReady() );
+ } );
connect( ui->checkBoxReusePassword, &QCheckBox::stateChanged,
this, [this]( int checked )
{
@@ -105,6 +112,8 @@ UsersPage::UsersPage( QWidget* parent )
setWriteRootPassword( true );
ui->checkBoxReusePassword->setChecked( true );
+ ui->checkBoxValidatePassword->setChecked( true );
+ ui->checkBoxValidatePassword->setVisible( false );
// Don't expand the explanations to "stupid wide", but keep them vaguely as-wide-as
// the things they are explaining.
@@ -387,6 +396,7 @@ UsersPage::onPasswordTextChanged( const QString& )
{
QString pw1 = ui->textBoxUserPassword->text();
QString pw2 = ui->textBoxUserVerifiedPassword->text();
+ m_readyPassword = true;
// TODO: 3.3: remove empty-check and leave it to passwordRequirements
if ( pw1.isEmpty() && pw2.isEmpty() )
@@ -403,23 +413,24 @@ UsersPage::onPasswordTextChanged( const QString& )
}
else
{
- bool ok = true;
- for ( auto pc : m_passwordChecks )
+ if ( ui->checkBoxValidatePassword->isChecked() )
{
- QString s = pc.filter( pw1 );
- if ( !s.isEmpty() )
+ for ( auto pc : m_passwordChecks )
{
- labelError( ui->labelUserPassword, ui->labelUserPasswordError, s );
- ok = false;
- m_readyPassword = false;
- break;
+ QString s = pc.filter( pw1 );
+
+ if ( !s.isEmpty() )
+ {
+ labelError( ui->labelUserPassword, ui->labelUserPasswordError, s );
+ m_readyPassword = false;
+ break;
+ }
}
}
- if ( ok )
+ if ( m_readyPassword )
{
labelOk( ui->labelUserPassword, ui->labelUserPasswordError );
- m_readyPassword = true;
}
}
@@ -431,6 +442,7 @@ UsersPage::onRootPasswordTextChanged( const QString& )
{
QString pw1 = ui->textBoxRootPassword->text();
QString pw2 = ui->textBoxVerifiedRootPassword->text();
+ m_readyRootPassword = true;
// TODO: 3.3: remove empty-check and leave it to passwordRequirements
if ( pw1.isEmpty() && pw2.isEmpty() )
@@ -447,23 +459,24 @@ UsersPage::onRootPasswordTextChanged( const QString& )
}
else
{
- bool ok = true;
- for ( auto pc : m_passwordChecks )
+ if ( ui->checkBoxValidatePassword->isChecked() )
{
- QString s = pc.filter( pw1 );
- if ( !s.isEmpty() )
+ for ( auto pc : m_passwordChecks )
{
- labelError( ui->labelRootPassword, ui->labelRootPasswordError, s );
- ok = false;
- m_readyRootPassword = false;
- break;
+ QString s = pc.filter( pw1 );
+
+ if ( !s.isEmpty() )
+ {
+ labelError( ui->labelRootPassword, ui->labelRootPasswordError, s );
+ m_readyRootPassword = false;
+ break;
+ }
}
}
- if ( ok )
+ if ( m_readyRootPassword )
{
labelOk( ui->labelRootPassword, ui->labelRootPasswordError );
- m_readyRootPassword = true;
}
}
@@ -471,6 +484,19 @@ UsersPage::onRootPasswordTextChanged( const QString& )
}
+void
+UsersPage::setPasswordCheckboxVisible( bool visible )
+{
+ ui->checkBoxValidatePassword->setVisible( visible );
+}
+
+void
+UsersPage::setValidatePasswordDefault( bool checked )
+{
+ ui->checkBoxValidatePassword->setChecked( checked );
+ emit checkReady( isReady() );
+}
+
void
UsersPage::setAutologinDefault( bool checked )
{
@@ -501,7 +527,7 @@ UsersPage::addPasswordCheck( const QString& key, const QVariant& value )
{
add_check_libpwquality( m_passwordChecks, value );
}
-#endif
+#endif // CHECK_PWQUALITY
else
cWarning() << "Unknown password-check key" << key;
}
diff --git a/src/modules/users/UsersPage.h b/src/modules/users/UsersPage.h
index ac1e1f9db..2dbe7aeda 100644
--- a/src/modules/users/UsersPage.h
+++ b/src/modules/users/UsersPage.h
@@ -48,6 +48,8 @@ public:
void onActivate();
void setWriteRootPassword( bool show );
+ void setPasswordCheckboxVisible( bool visible );
+ void setValidatePasswordDefault( bool checked );
void setAutologinDefault( bool checked );
void setReusePasswordDefault( bool checked );
diff --git a/src/modules/users/UsersViewStep.cpp b/src/modules/users/UsersViewStep.cpp
index 4582a9e85..676cb7236 100644
--- a/src/modules/users/UsersViewStep.cpp
+++ b/src/modules/users/UsersViewStep.cpp
@@ -173,6 +173,18 @@ UsersViewStep::setConfigurationMap( const QVariantMap& configurationMap )
}
}
+ if ( configurationMap.contains( "allowWeakPasswords" ) &&
+ configurationMap.value( "allowWeakPasswords" ).type() == QVariant::Bool )
+ {
+ m_widget->setPasswordCheckboxVisible( configurationMap.value( "allowWeakPasswords" ).toBool() );
+ }
+
+ if ( configurationMap.contains( "doPasswordChecks" ) &&
+ configurationMap.value( "doPasswordChecks" ).type() == QVariant::Bool )
+ {
+ m_widget->setValidatePasswordDefault( configurationMap.value( "doPasswordChecks" ).toBool() );
+ }
+
QString shell( QLatin1Literal( "/bin/bash" ) ); // as if it's not set at all
if ( configurationMap.contains( "userShell" ) )
shell = CalamaresUtils::getString( configurationMap, "userShell" );
diff --git a/src/modules/users/page_usersetup.ui b/src/modules/users/page_usersetup.ui
index c93912c01..ae74255c2 100644
--- a/src/modules/users/page_usersetup.ui
+++ b/src/modules/users/page_usersetup.ui
@@ -460,6 +460,13 @@
+ -
+
+
+ Require strong passwords.
+
+
+
-
diff --git a/src/modules/users/users.conf b/src/modules/users/users.conf
index 0c40faeff..0942e6b5d 100644
--- a/src/modules/users/users.conf
+++ b/src/modules/users/users.conf
@@ -28,7 +28,7 @@ defaultGroups:
# Disable when your Distribution does not require such a group.
autologinGroup: autologin
# You can control the initial state for the 'autologin checkbox' in UsersViewStep here.
-# Possible values are: true to enable or false to disable the checkbox by default
+# Possible values are: true to enable or false to disable the checkbox by default.
doAutologin: true
# When set to a non-empty string, Calamares creates a sudoers file for the user.
@@ -68,12 +68,23 @@ doReusePassword: true
#
# (additional checks may be implemented in CheckPWQuality.cpp and
# wired into UsersPage.cpp)
+#
+# To disable specific password validations,
+# comment out the relevant 'passwordRequirements' keys below.
+# To disable all password validations,
+# set both 'allowWeakPasswords' and 'doPasswordChecks' to false.
passwordRequirements:
minLength: -1 # Password at least this many characters
maxLength: -1 # Password at most this many characters
libpwquality:
- minlen=0
- minclass=0
+# You can control the visibility of the 'strong passwords' checkbox in UsersViewStep here.
+# Possible values are: true to show or false to hide the checkbox.
+allowWeakPasswords: true
+# You can control the initial state for the 'strong passwords' checkbox in UsersViewStep here.
+# Possible values are: true to enable or false to disable the checkbox by default.
+doPasswordChecks: true
# Shell to be used for the regular user of the target system.
# There are three possible kinds of settings: