plain.auth 0.12.1__py3-none-any.whl → 0.14.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 +21 -0
- plain/auth/__init__.py +6 -1
- plain/auth/middleware.py +5 -0
- plain/auth/test.py +40 -0
- {plain_auth-0.12.1.dist-info → plain_auth-0.14.0.dist-info}/METADATA +1 -1
- plain_auth-0.14.0.dist-info/RECORD +13 -0
- plain_auth-0.12.1.dist-info/RECORD +0 -11
- {plain_auth-0.12.1.dist-info → plain_auth-0.14.0.dist-info}/WHEEL +0 -0
- {plain_auth-0.12.1.dist-info → plain_auth-0.14.0.dist-info}/licenses/LICENSE +0 -0
plain/auth/CHANGELOG.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# plain-auth changelog
|
|
2
|
+
|
|
3
|
+
## [0.14.0](https://github.com/dropseed/plain/releases/plain-auth@0.14.0) (2025-07-18)
|
|
4
|
+
|
|
5
|
+
### What's changed
|
|
6
|
+
|
|
7
|
+
- Added OpenTelemetry tracing support with automatic user ID attribute setting in auth middleware ([b0224d0](https://github.com/dropseed/plain/commit/b0224d0418))
|
|
8
|
+
|
|
9
|
+
### Upgrade instructions
|
|
10
|
+
|
|
11
|
+
- No changes required
|
|
12
|
+
|
|
13
|
+
## [0.13.0](https://github.com/dropseed/plain/releases/plain-auth@0.13.0) (2025-06-23)
|
|
14
|
+
|
|
15
|
+
### What's changed
|
|
16
|
+
|
|
17
|
+
- 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)).
|
|
18
|
+
|
|
19
|
+
### Upgrade instructions
|
|
20
|
+
|
|
21
|
+
- No changes required
|
plain/auth/__init__.py
CHANGED
plain/auth/middleware.py
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
from opentelemetry import trace
|
|
2
|
+
from opentelemetry.semconv._incubating.attributes.user_attributes import USER_ID
|
|
3
|
+
|
|
1
4
|
from plain import auth
|
|
2
5
|
from plain.exceptions import ImproperlyConfigured
|
|
3
6
|
from plain.utils.functional import SimpleLazyObject
|
|
@@ -6,6 +9,8 @@ from plain.utils.functional import SimpleLazyObject
|
|
|
6
9
|
def get_user(request):
|
|
7
10
|
if not hasattr(request, "_cached_user"):
|
|
8
11
|
request._cached_user = auth.get_user(request)
|
|
12
|
+
if request._cached_user:
|
|
13
|
+
trace.get_current_span().set_attribute(USER_ID, request._cached_user.id)
|
|
9
14
|
return request._cached_user
|
|
10
15
|
|
|
11
16
|
|
plain/auth/test.py
ADDED
|
@@ -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()
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
plain/auth/CHANGELOG.md,sha256=HLL1Eg5zrQtrC1rm5X3-_KH9E2Mo5n9lvv9sS8Lq0uo,699
|
|
2
|
+
plain/auth/README.md,sha256=RJ8ry-ukLtLqcjRVAZ5cd1JgCr-JcUTi_9Kkg4kGmHc,2408
|
|
3
|
+
plain/auth/__init__.py,sha256=Id4ON6caLuZoZhu_kL6aMrwnN3Y8gPGVrVGs_V3ofAE,142
|
|
4
|
+
plain/auth/default_settings.py,sha256=65VzDn3j61OMn78Lg6Zuds4A8QKzJJ_0G9KoFqAOIRo,466
|
|
5
|
+
plain/auth/middleware.py,sha256=yiuJ6jg4PW5FpGFEzOzg5SLTjcheRTVPvo4NlmeBKws,1186
|
|
6
|
+
plain/auth/sessions.py,sha256=GCfXyGQhdSvMwKK3DpqK7fYjw2PiKbcZisWfrEeTRVM,5802
|
|
7
|
+
plain/auth/test.py,sha256=KfZSiX9S0p3AtCFAS4dUz4ctGIpOmLAGR-8nxAtM2TY,1163
|
|
8
|
+
plain/auth/utils.py,sha256=eEON0Mo928l-aW5tqBuoTdVke8aP4majxVtAFoLroSE,1280
|
|
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,,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
plain/auth/README.md,sha256=RJ8ry-ukLtLqcjRVAZ5cd1JgCr-JcUTi_9Kkg4kGmHc,2408
|
|
2
|
-
plain/auth/__init__.py,sha256=oDOVSov5os1_l-hYNlGd5hb6vy0rF5Q3VMRV1UOZeFU,123
|
|
3
|
-
plain/auth/default_settings.py,sha256=65VzDn3j61OMn78Lg6Zuds4A8QKzJJ_0G9KoFqAOIRo,466
|
|
4
|
-
plain/auth/middleware.py,sha256=K7e9n5vMvGnALKcjG92AhWQMsZ8brIuS9M9zNZqt_RI,954
|
|
5
|
-
plain/auth/sessions.py,sha256=GCfXyGQhdSvMwKK3DpqK7fYjw2PiKbcZisWfrEeTRVM,5802
|
|
6
|
-
plain/auth/utils.py,sha256=eEON0Mo928l-aW5tqBuoTdVke8aP4majxVtAFoLroSE,1280
|
|
7
|
-
plain/auth/views.py,sha256=_igztEBQKSM4CZro2lvlK0m01eIksqbmyux4w8gY1ks,4095
|
|
8
|
-
plain_auth-0.12.1.dist-info/METADATA,sha256=Nq3c1OB-qJK5pzwElsyoQqGbz8mrUUYTZnkHQHKVKWc,2762
|
|
9
|
-
plain_auth-0.12.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
10
|
-
plain_auth-0.12.1.dist-info/licenses/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
|
|
11
|
-
plain_auth-0.12.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|