plain.auth 0.14.0__py3-none-any.whl → 0.15.0__py3-none-any.whl

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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # plain-auth changelog
2
2
 
3
+ ## [0.15.0](https://github.com/dropseed/plain/releases/plain-auth@0.15.0) (2025-07-22)
4
+
5
+ ### What's changed
6
+
7
+ - Replaced `pk` field references with `id` field references in session management ([4b8fa6a](https://github.com/dropseed/plain/commit/4b8fa6aef1))
8
+ - Simplified user ID handling in sessions by using direct integer storage instead of field serialization ([4b8fa6a](https://github.com/dropseed/plain/commit/4b8fa6aef1))
9
+
10
+ ### Upgrade instructions
11
+
12
+ - No changes required
13
+
3
14
  ## [0.14.0](https://github.com/dropseed/plain/releases/plain-auth@0.14.0) (2025-07-18)
4
15
 
5
16
  ### What's changed
plain/auth/sessions.py CHANGED
@@ -8,12 +8,6 @@ USER_ID_SESSION_KEY = "_auth_user_id"
8
8
  USER_HASH_SESSION_KEY = "_auth_user_hash"
9
9
 
10
10
 
11
- def _get_user_id_from_session(request):
12
- # This value in the session is always serialized to a string, so we need
13
- # to convert it back to Python whenever we access it.
14
- return get_user_model()._meta.pk.to_python(request.session[USER_ID_SESSION_KEY])
15
-
16
-
17
11
  def get_session_auth_hash(user):
18
12
  """
19
13
  Return an HMAC of the password field.
@@ -62,7 +56,7 @@ def login(request, user):
62
56
  session_auth_hash = ""
63
57
 
64
58
  if USER_ID_SESSION_KEY in request.session:
65
- if _get_user_id_from_session(request) != user.pk:
59
+ if int(request.session[USER_ID_SESSION_KEY]) != user.id:
66
60
  # To avoid reusing another user's session, create a new, empty
67
61
  # session if the existing session corresponds to a different
68
62
  # authenticated user.
@@ -78,7 +72,7 @@ def login(request, user):
78
72
  # typically done after user login to prevent session fixation attacks.
79
73
  request.session.cycle_key()
80
74
 
81
- request.session[USER_ID_SESSION_KEY] = user._meta.pk.value_to_string(user)
75
+ request.session[USER_ID_SESSION_KEY] = user.id
82
76
  request.session[USER_HASH_SESSION_KEY] = session_auth_hash
83
77
  if hasattr(request, "user"):
84
78
  request.user = user
@@ -121,11 +115,9 @@ def get_user(request):
121
115
  if USER_ID_SESSION_KEY not in request.session:
122
116
  return None
123
117
 
124
- user_id = _get_user_id_from_session(request)
125
-
126
118
  UserModel = get_user_model()
127
119
  try:
128
- user = UserModel._default_manager.get(pk=user_id)
120
+ user = UserModel._default_manager.get(id=request.session[USER_ID_SESSION_KEY])
129
121
  except UserModel.DoesNotExist:
130
122
  return None
131
123
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plain.auth
3
- Version: 0.14.0
3
+ Version: 0.15.0
4
4
  Summary: User authentication and authorization for Plain.
5
5
  Author-email: Dave Gaeddert <dave.gaeddert@dropseed.dev>
6
6
  License-File: LICENSE
@@ -1,13 +1,13 @@
1
- plain/auth/CHANGELOG.md,sha256=HLL1Eg5zrQtrC1rm5X3-_KH9E2Mo5n9lvv9sS8Lq0uo,699
1
+ plain/auth/CHANGELOG.md,sha256=0P03xkDAmY9b6X2bnifK9ZRB0egyPEVhl8pFzB0VDhk,1174
2
2
  plain/auth/README.md,sha256=RJ8ry-ukLtLqcjRVAZ5cd1JgCr-JcUTi_9Kkg4kGmHc,2408
3
3
  plain/auth/__init__.py,sha256=Id4ON6caLuZoZhu_kL6aMrwnN3Y8gPGVrVGs_V3ofAE,142
4
4
  plain/auth/default_settings.py,sha256=65VzDn3j61OMn78Lg6Zuds4A8QKzJJ_0G9KoFqAOIRo,466
5
5
  plain/auth/middleware.py,sha256=yiuJ6jg4PW5FpGFEzOzg5SLTjcheRTVPvo4NlmeBKws,1186
6
- plain/auth/sessions.py,sha256=GCfXyGQhdSvMwKK3DpqK7fYjw2PiKbcZisWfrEeTRVM,5802
6
+ plain/auth/sessions.py,sha256=6G9-DGzenzx5yjc6wf7_giPuCo7IqIyc5_n8GLHnFAA,5498
7
7
  plain/auth/test.py,sha256=KfZSiX9S0p3AtCFAS4dUz4ctGIpOmLAGR-8nxAtM2TY,1163
8
8
  plain/auth/utils.py,sha256=eEON0Mo928l-aW5tqBuoTdVke8aP4majxVtAFoLroSE,1280
9
9
  plain/auth/views.py,sha256=_igztEBQKSM4CZro2lvlK0m01eIksqbmyux4w8gY1ks,4095
10
- plain_auth-0.14.0.dist-info/METADATA,sha256=blTwTTPWEtlXD_SiajyHmObWXU_mLuyoCWnfwO2vmqo,2762
11
- plain_auth-0.14.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
12
- plain_auth-0.14.0.dist-info/licenses/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
13
- plain_auth-0.14.0.dist-info/RECORD,,
10
+ plain_auth-0.15.0.dist-info/METADATA,sha256=pEpCQM-cGEihqHFhgPzDKxrO7uyKkaRiPCINdD0sUEA,2762
11
+ plain_auth-0.15.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
12
+ plain_auth-0.15.0.dist-info/licenses/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
13
+ plain_auth-0.15.0.dist-info/RECORD,,