plain.auth 0.11.0__tar.gz → 0.12.1__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,3 +11,7 @@ plain*/tests/.plain
11
11
 
12
12
  # Ottobot
13
13
  .aider*
14
+
15
+ /llms-full.txt
16
+
17
+ /.plain
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plain.auth
3
- Version: 0.11.0
3
+ Version: 0.12.1
4
4
  Summary: User authentication and authorization for Plain.
5
5
  Author-email: Dave Gaeddert <dave.gaeddert@dropseed.dev>
6
6
  License-File: LICENSE
@@ -22,6 +22,7 @@ class AuthenticationMiddleware:
22
22
  "'plain.sessions.middleware.SessionMiddleware' before "
23
23
  "'plain.auth.middleware.AuthenticationMiddleware'."
24
24
  )
25
+
25
26
  request.user = SimpleLazyObject(lambda: get_user(request))
26
- response = self.get_response(request)
27
- return response
27
+
28
+ return self.get_response(request)
@@ -21,6 +21,20 @@ def get_session_auth_hash(user):
21
21
  return _get_session_auth_hash(user)
22
22
 
23
23
 
24
+ def update_session_auth_hash(request, user):
25
+ """
26
+ Updating a user's password (for example) logs out all sessions for the user.
27
+
28
+ Take the current request and the updated user object from which the new
29
+ session hash will be derived and update the session hash appropriately to
30
+ prevent a password change from logging out the session from which the
31
+ password was changed.
32
+ """
33
+ request.session.cycle_key()
34
+ if request.user == user:
35
+ request.session[USER_HASH_SESSION_KEY] = get_session_auth_hash(user)
36
+
37
+
24
38
  def get_session_auth_fallback_hash(user):
25
39
  for fallback_secret in settings.SECRET_KEY_FALLBACKS:
26
40
  yield _get_session_auth_hash(user, secret=fallback_secret)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "plain.auth"
3
- version = "0.11.0"
3
+ version = "0.12.1"
4
4
  description = "User authentication and authorization for Plain."
5
5
  authors = [{name = "Dave Gaeddert", email = "dave.gaeddert@dropseed.dev"}]
6
6
  readme = "README.md"
@@ -8,6 +8,8 @@ requires-python = ">=3.11"
8
8
  dependencies = [
9
9
  "plain<1.0.0",
10
10
  "plain.models<1.0.0",
11
+ # Technically you can swap out sessions entirely with your own,
12
+ # so long as the request.session exists and has a similar API.
11
13
  "plain.sessions<1.0.0",
12
14
  ]
13
15
 
File without changes
File without changes