plain.auth 0.17.0__tar.gz → 0.18.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {plain_auth-0.17.0 → plain_auth-0.18.0}/.gitignore +0 -2
- {plain_auth-0.17.0 → plain_auth-0.18.0}/PKG-INFO +1 -1
- {plain_auth-0.17.0 → plain_auth-0.18.0}/plain/auth/CHANGELOG.md +10 -0
- {plain_auth-0.17.0 → plain_auth-0.18.0}/plain/auth/sessions.py +12 -6
- {plain_auth-0.17.0 → plain_auth-0.18.0}/pyproject.toml +1 -1
- {plain_auth-0.17.0 → plain_auth-0.18.0}/LICENSE +0 -0
- {plain_auth-0.17.0 → plain_auth-0.18.0}/README.md +0 -0
- {plain_auth-0.17.0 → plain_auth-0.18.0}/plain/auth/README.md +0 -0
- {plain_auth-0.17.0 → plain_auth-0.18.0}/plain/auth/__init__.py +0 -0
- {plain_auth-0.17.0 → plain_auth-0.18.0}/plain/auth/default_settings.py +0 -0
- {plain_auth-0.17.0 → plain_auth-0.18.0}/plain/auth/middleware.py +0 -0
- {plain_auth-0.17.0 → plain_auth-0.18.0}/plain/auth/test.py +0 -0
- {plain_auth-0.17.0 → plain_auth-0.18.0}/plain/auth/utils.py +0 -0
- {plain_auth-0.17.0 → plain_auth-0.18.0}/plain/auth/views.py +0 -0
- {plain_auth-0.17.0 → plain_auth-0.18.0}/tests/app/settings.py +0 -0
- {plain_auth-0.17.0 → plain_auth-0.18.0}/tests/app/urls.py +0 -0
- {plain_auth-0.17.0 → plain_auth-0.18.0}/tests/app/users/migrations/0001_initial.py +0 -0
- {plain_auth-0.17.0 → plain_auth-0.18.0}/tests/app/users/migrations/__init__.py +0 -0
- {plain_auth-0.17.0 → plain_auth-0.18.0}/tests/app/users/models.py +0 -0
- {plain_auth-0.17.0 → plain_auth-0.18.0}/tests/test_views.py +0 -0
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# plain-auth changelog
|
|
2
2
|
|
|
3
|
+
## [0.18.0](https://github.com/dropseed/plain/releases/plain-auth@0.18.0) (2025-09-19)
|
|
4
|
+
|
|
5
|
+
### What's changed
|
|
6
|
+
|
|
7
|
+
- Removed deprecated `constant_time_compare` utility function, replaced with Python's built-in `hmac.compare_digest()` for improved security in session management ([55f3f55](https://github.com/dropseed/plain/commit/55f3f5596d))
|
|
8
|
+
|
|
9
|
+
### Upgrade instructions
|
|
10
|
+
|
|
11
|
+
- No changes required
|
|
12
|
+
|
|
3
13
|
## [0.17.0](https://github.com/dropseed/plain/releases/plain-auth@0.17.0) (2025-09-12)
|
|
4
14
|
|
|
5
15
|
### What's changed
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import hmac
|
|
2
|
+
|
|
1
3
|
from plain.exceptions import ImproperlyConfigured
|
|
2
4
|
from plain.models import models_registry
|
|
3
5
|
from plain.runtime import settings
|
|
4
|
-
from plain.utils.crypto import
|
|
6
|
+
from plain.utils.crypto import salted_hmac
|
|
7
|
+
from plain.utils.encoding import force_bytes
|
|
5
8
|
|
|
6
9
|
USER_ID_SESSION_KEY = "_auth_user_id"
|
|
7
10
|
USER_HASH_SESSION_KEY = "_auth_user_hash"
|
|
@@ -60,8 +63,9 @@ def login(request, user):
|
|
|
60
63
|
# session if the existing session corresponds to a different
|
|
61
64
|
# authenticated user.
|
|
62
65
|
request.session.flush()
|
|
63
|
-
elif session_auth_hash and not
|
|
64
|
-
request.session.get(USER_HASH_SESSION_KEY, ""),
|
|
66
|
+
elif session_auth_hash and not hmac.compare_digest(
|
|
67
|
+
force_bytes(request.session.get(USER_HASH_SESSION_KEY, "")),
|
|
68
|
+
force_bytes(session_auth_hash),
|
|
65
69
|
):
|
|
66
70
|
# If the session hash does not match the current hash, reset the
|
|
67
71
|
# session. Most likely this means the password was changed.
|
|
@@ -131,15 +135,17 @@ def get_user(request):
|
|
|
131
135
|
session_hash_verified = False
|
|
132
136
|
else:
|
|
133
137
|
session_auth_hash = get_session_auth_hash(user)
|
|
134
|
-
session_hash_verified =
|
|
135
|
-
session_hash, session_auth_hash
|
|
138
|
+
session_hash_verified = hmac.compare_digest(
|
|
139
|
+
force_bytes(session_hash), force_bytes(session_auth_hash)
|
|
136
140
|
)
|
|
137
141
|
if not session_hash_verified:
|
|
138
142
|
# If the current secret does not verify the session, try
|
|
139
143
|
# with the fallback secrets and stop when a matching one is
|
|
140
144
|
# found.
|
|
141
145
|
if session_hash and any(
|
|
142
|
-
|
|
146
|
+
hmac.compare_digest(
|
|
147
|
+
force_bytes(session_hash), force_bytes(fallback_auth_hash)
|
|
148
|
+
)
|
|
143
149
|
for fallback_auth_hash in get_session_auth_fallback_hash(user)
|
|
144
150
|
):
|
|
145
151
|
request.session.cycle_key()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|