plain.auth 0.12.0__tar.gz → 0.13.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.12.0 → plain_auth-0.13.0}/.gitignore +5 -0
- {plain_auth-0.12.0 → plain_auth-0.13.0}/PKG-INFO +1 -1
- plain_auth-0.13.0/plain/auth/CHANGELOG.md +11 -0
- plain_auth-0.13.0/plain/auth/__init__.py +8 -0
- {plain_auth-0.12.0 → plain_auth-0.13.0}/plain/auth/middleware.py +3 -2
- plain_auth-0.13.0/plain/auth/test.py +40 -0
- {plain_auth-0.12.0 → plain_auth-0.13.0}/pyproject.toml +3 -1
- plain_auth-0.12.0/plain/auth/__init__.py +0 -3
- {plain_auth-0.12.0 → plain_auth-0.13.0}/LICENSE +0 -0
- {plain_auth-0.12.0 → plain_auth-0.13.0}/README.md +0 -0
- {plain_auth-0.12.0 → plain_auth-0.13.0}/plain/auth/README.md +0 -0
- {plain_auth-0.12.0 → plain_auth-0.13.0}/plain/auth/default_settings.py +0 -0
- {plain_auth-0.12.0 → plain_auth-0.13.0}/plain/auth/sessions.py +0 -0
- {plain_auth-0.12.0 → plain_auth-0.13.0}/plain/auth/utils.py +0 -0
- {plain_auth-0.12.0 → plain_auth-0.13.0}/plain/auth/views.py +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# plain-auth changelog
|
|
2
|
+
|
|
3
|
+
## [0.13.0](https://github.com/dropseed/plain/releases/plain-auth@0.13.0) (2025-06-23)
|
|
4
|
+
|
|
5
|
+
### What's changed
|
|
6
|
+
|
|
7
|
+
- Added `login_client` and `logout_client` helpers to `plain.auth.test` for easily logging users in and out of the Django test client ([eb8a023](https://github.com/dropseed/plain/commit/eb8a023)).
|
|
8
|
+
|
|
9
|
+
### Upgrade instructions
|
|
10
|
+
|
|
11
|
+
- No changes required
|
|
@@ -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
|
-
|
|
27
|
-
return
|
|
27
|
+
|
|
28
|
+
return self.get_response(request)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from http.cookies import SimpleCookie
|
|
2
|
+
|
|
3
|
+
from plain.http.request import HttpRequest
|
|
4
|
+
from plain.runtime import settings
|
|
5
|
+
from plain.sessions import SessionStore
|
|
6
|
+
|
|
7
|
+
from .sessions import get_user, login, logout
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def login_client(client, user):
|
|
11
|
+
"""Log a user into a test client."""
|
|
12
|
+
request = HttpRequest()
|
|
13
|
+
if client.session:
|
|
14
|
+
request.session = client.session
|
|
15
|
+
else:
|
|
16
|
+
request.session = SessionStore()
|
|
17
|
+
login(request, user)
|
|
18
|
+
request.session.save()
|
|
19
|
+
session_cookie = settings.SESSION_COOKIE_NAME
|
|
20
|
+
client.cookies[session_cookie] = request.session.session_key
|
|
21
|
+
cookie_data = {
|
|
22
|
+
"max-age": None,
|
|
23
|
+
"path": "/",
|
|
24
|
+
"domain": settings.SESSION_COOKIE_DOMAIN,
|
|
25
|
+
"secure": settings.SESSION_COOKIE_SECURE or None,
|
|
26
|
+
"expires": None,
|
|
27
|
+
}
|
|
28
|
+
client.cookies[session_cookie].update(cookie_data)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def logout_client(client):
|
|
32
|
+
"""Log out a user from a test client."""
|
|
33
|
+
request = HttpRequest()
|
|
34
|
+
if client.session:
|
|
35
|
+
request.session = client.session
|
|
36
|
+
request.user = get_user(request)
|
|
37
|
+
else:
|
|
38
|
+
request.session = SessionStore()
|
|
39
|
+
logout(request)
|
|
40
|
+
client.cookies = SimpleCookie()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "plain.auth"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.13.0"
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|