Skip to content

Strong passwords for admins#9347

Merged
andreslucena merged 64 commits intodecidim:developfrom
mainio:feature/strong_passwords_for_admins
Jun 23, 2022
Merged

Strong passwords for admins#9347
andreslucena merged 64 commits intodecidim:developfrom
mainio:feature/strong_passwords_for_admins

Conversation

@lahdeero
Copy link
Copy Markdown
Contributor

@lahdeero lahdeero commented May 20, 2022

🎩 What? Why?

Adds configurable option to require strong passwords for admins. When option is set to true admins are asked to update their passwords to strong passwords after they log in.

NOTE: If you are using seeds admin's default password has changed to decidim123456789

📌 Related Issues

Fixes #9178

Testing

  1. Decidim::User.find(1).update(password_updated_at: nil)
  2. Login with user with id 1 ( admin@example.org )
  3. See "Change your password" view

📷 Screenshots

image

♥️ Thank you!

@lahdeero lahdeero changed the title Initial Strong passwords for admins May 20, 2022
@lahdeero lahdeero marked this pull request as ready for review May 23, 2022 14:03
@lahdeero lahdeero requested a review from ahukkanen May 23, 2022 14:03
@ahukkanen
Copy link
Copy Markdown
Contributor

NOTE: If you are using seeds admin's default password has changed to decidim123456789

Can we also update this to the docs @lahdeero ?

https://github.com/decidim/decidim/blob/develop/docs/modules/install/pages/index.adoc#initializing-your-app-for-local-development

@andreslucena andreslucena linked an issue Jun 14, 2022 that may be closed by this pull request
7 tasks
@ahukkanen ahukkanen marked this pull request as draft June 15, 2022 09:16
@ahukkanen
Copy link
Copy Markdown
Contributor

All changes done @andreslucena.

@ahukkanen ahukkanen requested a review from andreslucena June 20, 2022 16:53
Copy link
Copy Markdown
Member

@andreslucena andreslucena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last minute change, sorry! Talking with other people from @decidim/product, and we agreed that it can be difficult to have two seed passwords (one for admins and another for users). Can you change the default seed password to decidim123456789 to everyone 🙏🏽? Thanks

For consistency reasons, use the same password for regular users
and administrators after adding the stronger administrator
password rules.
@ahukkanen
Copy link
Copy Markdown
Contributor

Done @andreslucena

@ahukkanen ahukkanen requested a review from andreslucena June 22, 2022 16:39
Copy link
Copy Markdown
Member

@andreslucena andreslucena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏽 👍🏽

@andreslucena andreslucena merged commit 542e53e into decidim:develop Jun 23, 2022
@ahukkanen ahukkanen deleted the feature/strong_passwords_for_admins branch June 27, 2022 10:30
andreslucena added a commit that referenced this pull request Jun 29, 2022
* Initial

* Cant reuse old passwords

* Update user seeds and factory

* Update previous passwords and change time in model

* Update seeds

* Update passowrd in invite admin spec

* Lock user to change password view

* Show error when passwords doesnt match

* Add validator test and update comments

* Change method names

* Add secondary notification to change password page

* Update admins default password to docs

* Rename the commands and forms (remove admin from the names)

* Rename the password change paths

* Do not log out the user after successful password change

* Refine the change password translations

* Show the required indicator for the password change fields

* Require the password change also for the admin panel

* Fix the migration, simplify the logic and improve its performance

* Fix the form class name in the password form spec

* Fix correct page title expectation for the admin password change spec

* DRY password validator + do not disable the rest of the validations for admins

* Make attr_readers private as they are only used within the command

* Better naming for the concern methods

* Do not require permissions to access the change password page

* Simplify the password confirmation check in the form

* Correct SoC

Refactor the needs_password_update? method to the correct place

* Move the admin password validators to the PasswordValidator class

To simplify the logic where this is used, let's have these all in
the same validator.

* Simplify generating the password field options

* Remove the strong admin password validation from the user model

This is now part of the PasswordValidator so we don't need to
manually validate it in the model either.

* Remove spec for removed class

* Limit the password change routes for signed in user

* Move the admin password validation specs to the password validator spec

* Move the strong password validation error message to correct place

* Fix the admin password validation system specs after modifying messages

* Move the password validator spec to correct folder

* Move the checks for the password change save to the hook method

* Remove unnecessary controller method

* Simlify the admin check

* Remove unused i18n key

* Skip password repeated validation if disabled or password was not changed

* Do not compare empty passwords in the password repeated check

* Fix the password validator spec after the latest changes

* Fix the user test factory after the admin password validation changes

* Set the user factory password at the after `:build` hook

* Do not add the `required` attribute on the label element

* Delete the `required` option from the i18n label

* Fix the authentication spec after applying the front-end rules

After applying the front-end rules (min and max length) to the
password fields, the authentication spec was broken.

* Mark the protected methods as private

As the PasswordValidator is no longer extended, let's mark these
methods as private.

* System spec for user cannot enter the admin panel if password expired

* Only return admin password length when the feature is enabled

Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com>

* Update the admin password in the install docs

* Allow configuring the admin password configs through ENV vars

* Test the admin env vars

* Refine the admin password configuration names after introducing ENV vars

Make the admin password configuration options match the ENV var
names a bit better.

* Add documentation for the admin password ENV vars

* Add CHANGELOG entry for the strong admin passwords feature

* Change the default password form decidim123456 to decidim123456789

For consistency reasons, use the same password for regular users
and administrators after adding the stronger administrator
password rules.

* For consistency, change the system admin example password

Co-authored-by: Eero Lahdenperä <eero.lahdenpera@mainiotech.fi>
Co-authored-by: Antti Hukkanen <antti.hukkanen@mainiotech.fi>
Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com>
andreslucena added a commit that referenced this pull request Jul 6, 2022
* Initial

* Cant reuse old passwords

* Update user seeds and factory

* Update previous passwords and change time in model

* Update seeds

* Update passowrd in invite admin spec

* Lock user to change password view

* Show error when passwords doesnt match

* Add validator test and update comments

* Change method names

* Add secondary notification to change password page

* Update admins default password to docs

* Rename the commands and forms (remove admin from the names)

* Rename the password change paths

* Do not log out the user after successful password change

* Refine the change password translations

* Show the required indicator for the password change fields

* Require the password change also for the admin panel

* Fix the migration, simplify the logic and improve its performance

* Fix the form class name in the password form spec

* Fix correct page title expectation for the admin password change spec

* DRY password validator + do not disable the rest of the validations for admins

* Make attr_readers private as they are only used within the command

* Better naming for the concern methods

* Do not require permissions to access the change password page

* Simplify the password confirmation check in the form

* Correct SoC

Refactor the needs_password_update? method to the correct place

* Move the admin password validators to the PasswordValidator class

To simplify the logic where this is used, let's have these all in
the same validator.

* Simplify generating the password field options

* Remove the strong admin password validation from the user model

This is now part of the PasswordValidator so we don't need to
manually validate it in the model either.

* Remove spec for removed class

* Limit the password change routes for signed in user

* Move the admin password validation specs to the password validator spec

* Move the strong password validation error message to correct place

* Fix the admin password validation system specs after modifying messages

* Move the password validator spec to correct folder

* Move the checks for the password change save to the hook method

* Remove unnecessary controller method

* Simlify the admin check

* Remove unused i18n key

* Skip password repeated validation if disabled or password was not changed

* Do not compare empty passwords in the password repeated check

* Fix the password validator spec after the latest changes

* Fix the user test factory after the admin password validation changes

* Set the user factory password at the after `:build` hook

* Do not add the `required` attribute on the label element

* Delete the `required` option from the i18n label

* Fix the authentication spec after applying the front-end rules

After applying the front-end rules (min and max length) to the
password fields, the authentication spec was broken.

* Mark the protected methods as private

As the PasswordValidator is no longer extended, let's mark these
methods as private.

* System spec for user cannot enter the admin panel if password expired

* Only return admin password length when the feature is enabled

Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com>

* Update the admin password in the install docs

* Allow configuring the admin password configs through ENV vars

* Test the admin env vars

* Refine the admin password configuration names after introducing ENV vars

Make the admin password configuration options match the ENV var
names a bit better.

* Add documentation for the admin password ENV vars

* Add CHANGELOG entry for the strong admin passwords feature

* Change the default password form decidim123456 to decidim123456789

For consistency reasons, use the same password for regular users
and administrators after adding the stronger administrator
password rules.

* For consistency, change the system admin example password

Co-authored-by: Eero Lahdenperä <eero.lahdenpera@mainiotech.fi>
Co-authored-by: Antti Hukkanen <antti.hukkanen@mainiotech.fi>
Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com>
eliegaboriau pushed a commit to eliegaboriau/decidim that referenced this pull request Oct 25, 2022
* Initial

* Cant reuse old passwords

* Update user seeds and factory

* Update previous passwords and change time in model

* Update seeds

* Update passowrd in invite admin spec

* Lock user to change password view

* Show error when passwords doesnt match

* Add validator test and update comments

* Change method names

* Add secondary notification to change password page

* Update admins default password to docs

* Rename the commands and forms (remove admin from the names)

* Rename the password change paths

* Do not log out the user after successful password change

* Refine the change password translations

* Show the required indicator for the password change fields

* Require the password change also for the admin panel

* Fix the migration, simplify the logic and improve its performance

* Fix the form class name in the password form spec

* Fix correct page title expectation for the admin password change spec

* DRY password validator + do not disable the rest of the validations for admins

* Make attr_readers private as they are only used within the command

* Better naming for the concern methods

* Do not require permissions to access the change password page

* Simplify the password confirmation check in the form

* Correct SoC

Refactor the needs_password_update? method to the correct place

* Move the admin password validators to the PasswordValidator class

To simplify the logic where this is used, let's have these all in
the same validator.

* Simplify generating the password field options

* Remove the strong admin password validation from the user model

This is now part of the PasswordValidator so we don't need to
manually validate it in the model either.

* Remove spec for removed class

* Limit the password change routes for signed in user

* Move the admin password validation specs to the password validator spec

* Move the strong password validation error message to correct place

* Fix the admin password validation system specs after modifying messages

* Move the password validator spec to correct folder

* Move the checks for the password change save to the hook method

* Remove unnecessary controller method

* Simlify the admin check

* Remove unused i18n key

* Skip password repeated validation if disabled or password was not changed

* Do not compare empty passwords in the password repeated check

* Fix the password validator spec after the latest changes

* Fix the user test factory after the admin password validation changes

* Set the user factory password at the after `:build` hook

* Do not add the `required` attribute on the label element

* Delete the `required` option from the i18n label

* Fix the authentication spec after applying the front-end rules

After applying the front-end rules (min and max length) to the
password fields, the authentication spec was broken.

* Mark the protected methods as private

As the PasswordValidator is no longer extended, let's mark these
methods as private.

* System spec for user cannot enter the admin panel if password expired

* Only return admin password length when the feature is enabled

Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com>

* Update the admin password in the install docs

* Allow configuring the admin password configs through ENV vars

* Test the admin env vars

* Refine the admin password configuration names after introducing ENV vars

Make the admin password configuration options match the ENV var
names a bit better.

* Add documentation for the admin password ENV vars

* Add CHANGELOG entry for the strong admin passwords feature

* Change the default password form decidim123456 to decidim123456789

For consistency reasons, use the same password for regular users
and administrators after adding the stronger administrator
password rules.

* For consistency, change the system admin example password

Co-authored-by: Eero Lahdenperä <eero.lahdenpera@mainiotech.fi>
Co-authored-by: Antti Hukkanen <antti.hukkanen@mainiotech.fi>
Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com>
@alecslupu alecslupu added this to the 0.27.0 milestone Jul 14, 2023
armandfardeau added a commit to OpenSourcePolitics/decidim-module-friendly_signup that referenced this pull request Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: admin module: core project: GDPR Barcelona City Council contract

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Strong password policy for Admin users

4 participants