plain.auth 0.17.0__tar.gz → 0.19.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.
@@ -11,9 +11,8 @@ plain*/tests/.plain
11
11
  # Ottobot
12
12
  .aider*
13
13
 
14
- /llms-full.txt
15
-
16
14
  # Plain temp dirs
17
15
  .plain
18
16
 
19
17
  .vscode
18
+ /.claude
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plain.auth
3
- Version: 0.17.0
3
+ Version: 0.19.0
4
4
  Summary: Add users to your app and decide what they can access.
5
5
  Author-email: Dave Gaeddert <dave.gaeddert@dropseed.dev>
6
6
  License-File: LICENSE
@@ -1,5 +1,25 @@
1
1
  # plain-auth changelog
2
2
 
3
+ ## [0.19.0](https://github.com/dropseed/plain/releases/plain-auth@0.19.0) (2025-09-30)
4
+
5
+ ### What's changed
6
+
7
+ - Updated imports to use the renamed `Request` class instead of `HttpRequest` ([cd46ff2](https://github.com/dropseed/plain/commit/cd46ff2003))
8
+
9
+ ### Upgrade instructions
10
+
11
+ - Replace any imports of `HttpRequest` from `plain.http.request` with `Request` (e.g., `from plain.http.request import HttpRequest` becomes `from plain.http.request import Request`)
12
+
13
+ ## [0.18.0](https://github.com/dropseed/plain/releases/plain-auth@0.18.0) (2025-09-19)
14
+
15
+ ### What's changed
16
+
17
+ - 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))
18
+
19
+ ### Upgrade instructions
20
+
21
+ - No changes required
22
+
3
23
  ## [0.17.0](https://github.com/dropseed/plain/releases/plain-auth@0.17.0) (2025-09-12)
4
24
 
5
25
  ### 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 constant_time_compare, salted_hmac
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 constant_time_compare(
64
- request.session.get(USER_HASH_SESSION_KEY, ""), session_auth_hash
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 = constant_time_compare(
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
- constant_time_compare(session_hash, fallback_auth_hash)
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()
@@ -1,6 +1,6 @@
1
1
  from http.cookies import SimpleCookie
2
2
 
3
- from plain.http.request import HttpRequest
3
+ from plain.http.request import Request
4
4
  from plain.runtime import settings
5
5
  from plain.sessions import SessionStore
6
6
 
@@ -9,7 +9,7 @@ from .sessions import get_user, login, logout
9
9
 
10
10
  def login_client(client, user):
11
11
  """Log a user into a test client."""
12
- request = HttpRequest()
12
+ request = Request()
13
13
  if client.session:
14
14
  request.session = client.session
15
15
  else:
@@ -30,7 +30,7 @@ def login_client(client, user):
30
30
 
31
31
  def logout_client(client):
32
32
  """Log out a user from a test client."""
33
- request = HttpRequest()
33
+ request = Request()
34
34
  if client.session:
35
35
  request.session = client.session
36
36
  request.user = get_user(request)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "plain.auth"
3
- version = "0.17.0"
3
+ version = "0.19.0"
4
4
  description = "Add users to your app and decide what they can access."
5
5
  authors = [{name = "Dave Gaeddert", email = "dave.gaeddert@dropseed.dev"}]
6
6
  readme = "README.md"
File without changes
File without changes