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

Allow setting SECRET_KEY to be str or bytes, add SECRET_KEY_FALLBACKS, update PasswordResetTokenGenerator #1411

Conversation

christianbundy
Copy link
Contributor

@christianbundy christianbundy commented Mar 22, 2023

Problem: SECRET_KEY could be either str or bytes, and it doesn't look like we have any support for SECRET_KEY_FALLBACKS.

Solution: Fix type annotation and add SECRET_KEY_FALLBACKS. Also update usages in PasswordResetTokenGenerator.

See-also: https://github.com/django/django/pull/15198/files

Copy link
Collaborator

@intgr intgr left a comment

Choose a reason for hiding this comment

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

Indeed https://docs.djangoproject.com/en/4.2/ref/settings/#secret-key states

Uses of the key shouldn’t assume that it’s text or bytes. Every use should go through force_str() or force_bytes() to convert it to the desired type.

@intgr intgr changed the title Fix SECRET_KEY and add SECRET_KEY_FALLBACKS Allow setting SECRET_KEY to be str or bytes, and add SECRET_KEY_FALLBACKS Mar 31, 2023
@intgr intgr merged commit 4faa602 into typeddjango:master Mar 31, 2023
@intgr intgr changed the title Allow setting SECRET_KEY to be str or bytes, and add SECRET_KEY_FALLBACKS Allow setting SECRET_KEY to be str or bytes, add SECRET_KEY_FALLBACKS, update PasswordResetTokenGenerator Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants