Repository navigation
Generate temporary passwords with the secrets module - #2855
Merged
nhoening merged 2 commits intoNov 10, 2026
Merged
Conversation
set_random_password drew the password of a newly created user, and of a user whose password is reset, from the random module, which is not meant for security purposes. That password is the user's real password until they choose their own. Closes FlexMeasures#2854 Signed-off-by: Serhii <jshmitz@me.com>
Signed-off-by: Serhii <jshmitz@me.com>
Documentation build overview
|
Flix6x
added a commit
that referenced
this pull request
Nov 11, 2026
The v1.1.1 patch release backports #2855, #2861, #2838, #2829, #2851, #2845, #2859, #2850 and #2860 to the 1.1.x branch. Move their changelog bullets out of the v1.2.0 section into a new v1.1.1 section, worded and ordered as on 1.1.x, so the same fixes are not listed as unreleased once 1.1.1 ships. The bullet for #2861 takes the 1.1.x wording, which adds that Python 3.10 keeps the earlier Pillow, dnspython and filelock. The API change log needs no split: v3.0-35 holds only #2859, which ships in v1.1.1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: F.N. Claessen <felix@seita.nl>
Flix6x
added a commit
that referenced
this pull request
Nov 11, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: F.N. Claessen <felix@seita.nl>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
set_random_passworddraws the temporary password withsecrets.choiceinstead ofrandom.choicedocumentation/changelog.rstThat password is the real password of a newly created user, and of a user whose password is reset, until they choose their own through the emailed link. As written in #2854, I found no way to predict it today, so this is hardening and not the fix of a vulnerability.
Look & Feel
Nothing changes for users: the password is still 24 lowercase letters, and it is still never shown or mailed.
How to test
pytest flexmeasures/data/tests/test_user_services.py::test_random_password_does_not_come_from_the_random_moduleThe test seeds the
randommodule with the same value twice and expects two different passwords. Withrandom.choiceput back it fails, because both passwords are then the same.The full suite gives 3463 passed and 7 failed on my machine. Those seven are the same ones that fail for me on the unchanged branch of #2849, as listed in #2853 (sorting by name under a
C.UTF-8collation,test_numerical_errors[cbc],test_closest_sensor).Further Improvements
None.
Related Items
Closes #2854
Sign-off