Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting a large PASSWORD_DURATION_SECONDS causes an error #42

Open
mikemanger opened this issue Oct 15, 2024 · 1 comment
Open

Setting a large PASSWORD_DURATION_SECONDS causes an error #42

mikemanger opened this issue Oct 15, 2024 · 1 comment

Comments

@mikemanger
Copy link

Setting PASSWORD_DURATION_SECONDS to a large value gives an overflow error.

# settings.py
# 23992800719976 seconds
PASSWORD_DURATION_SECONDS = 24 * 9999**3
Traceback (most recent call last):
  File "[DIR]/site-packages/password_policies/middleware.py", line 186, in process_request
    self.check = PasswordCheck(request.user)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "[DIR]/site-packages/password_policies/utils.py", line 16, in __init__
    self.expiry_datetime = self.get_expiry_datetime()
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "[DIR]/site-packages/password_policies/utils.py", line 49, in get_expiry_datetime
    return timezone.now() - timedelta(seconds=seconds)
           ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
OverflowError: date value out of range

Tested with python 3.12.

@mikemanger
Copy link
Author

I think worth catching and setting the value to timedelta.max.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant