plain.auth 0.21.0__tar.gz → 0.22.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.21.0 → plain_auth-0.22.0}/.gitignore +2 -0
- {plain_auth-0.21.0 → plain_auth-0.22.0}/PKG-INFO +1 -1
- {plain_auth-0.21.0 → plain_auth-0.22.0}/plain/auth/CHANGELOG.md +10 -0
- {plain_auth-0.21.0 → plain_auth-0.22.0}/plain/auth/views.py +6 -12
- {plain_auth-0.21.0 → plain_auth-0.22.0}/pyproject.toml +1 -1
- {plain_auth-0.21.0 → plain_auth-0.22.0}/tests/app/urls.py +5 -5
- plain_auth-0.22.0/tests/app/users/models.py +8 -0
- plain_auth-0.21.0/tests/app/users/models.py +0 -7
- {plain_auth-0.21.0 → plain_auth-0.22.0}/LICENSE +0 -0
- {plain_auth-0.21.0 → plain_auth-0.22.0}/README.md +0 -0
- {plain_auth-0.21.0 → plain_auth-0.22.0}/plain/auth/README.md +0 -0
- {plain_auth-0.21.0 → plain_auth-0.22.0}/plain/auth/__init__.py +0 -0
- {plain_auth-0.21.0 → plain_auth-0.22.0}/plain/auth/default_settings.py +0 -0
- {plain_auth-0.21.0 → plain_auth-0.22.0}/plain/auth/requests.py +0 -0
- {plain_auth-0.21.0 → plain_auth-0.22.0}/plain/auth/sessions.py +0 -0
- {plain_auth-0.21.0 → plain_auth-0.22.0}/plain/auth/templates.py +0 -0
- {plain_auth-0.21.0 → plain_auth-0.22.0}/plain/auth/test.py +0 -0
- {plain_auth-0.21.0 → plain_auth-0.22.0}/plain/auth/utils.py +0 -0
- {plain_auth-0.21.0 → plain_auth-0.22.0}/tests/app/settings.py +0 -0
- {plain_auth-0.21.0 → plain_auth-0.22.0}/tests/app/users/migrations/0001_initial.py +0 -0
- {plain_auth-0.21.0 → plain_auth-0.22.0}/tests/app/users/migrations/__init__.py +0 -0
- {plain_auth-0.21.0 → plain_auth-0.22.0}/tests/test_views.py +0 -0
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# plain-auth changelog
|
|
2
2
|
|
|
3
|
+
## [0.22.0](https://github.com/dropseed/plain/releases/plain-auth@0.22.0) (2025-11-24)
|
|
4
|
+
|
|
5
|
+
### What's changed
|
|
6
|
+
|
|
7
|
+
- Replaced `AuthViewMixin` with `AuthView` class that inherits from `SessionView` for better typing and simpler view inheritance ([569afd6](https://github.com/dropseed/plain/commit/569afd606d))
|
|
8
|
+
|
|
9
|
+
### Upgrade instructions
|
|
10
|
+
|
|
11
|
+
- Replace `class MyView(AuthViewMixin, View)` with `class MyView(AuthView)` - the new `AuthView` class already inherits from the appropriate base classes
|
|
12
|
+
|
|
3
13
|
## [0.21.0](https://github.com/dropseed/plain/releases/plain-auth@0.21.0) (2025-11-12)
|
|
4
14
|
|
|
5
15
|
### What's changed
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from functools import cached_property
|
|
4
|
-
from typing import
|
|
4
|
+
from typing import Any
|
|
5
5
|
from urllib.parse import urlparse, urlunparse
|
|
6
6
|
|
|
7
7
|
from plain.exceptions import PermissionDenied
|
|
8
8
|
from plain.http import (
|
|
9
9
|
Http404,
|
|
10
10
|
QueryDict,
|
|
11
|
-
|
|
11
|
+
ResponseBase,
|
|
12
12
|
ResponseRedirect,
|
|
13
13
|
)
|
|
14
14
|
from plain.runtime import settings
|
|
15
|
-
from plain.sessions.views import
|
|
15
|
+
from plain.sessions.views import SessionView
|
|
16
16
|
from plain.urls import reverse
|
|
17
17
|
from plain.utils.cache import patch_cache_control
|
|
18
18
|
from plain.views import View
|
|
@@ -20,9 +20,6 @@ from plain.views import View
|
|
|
20
20
|
from .sessions import logout
|
|
21
21
|
from .utils import resolve_url
|
|
22
22
|
|
|
23
|
-
if TYPE_CHECKING:
|
|
24
|
-
from plain.http import Request
|
|
25
|
-
|
|
26
23
|
try:
|
|
27
24
|
from plain.admin.impersonate import get_request_impersonator
|
|
28
25
|
except ImportError:
|
|
@@ -35,13 +32,11 @@ class LoginRequired(Exception):
|
|
|
35
32
|
self.redirect_field_name = redirect_field_name
|
|
36
33
|
|
|
37
34
|
|
|
38
|
-
class
|
|
35
|
+
class AuthView(SessionView):
|
|
39
36
|
login_required = False
|
|
40
37
|
admin_required = False # Implies login_required
|
|
41
38
|
login_url = settings.AUTH_LOGIN_URL
|
|
42
39
|
|
|
43
|
-
request: Request
|
|
44
|
-
|
|
45
40
|
@cached_property
|
|
46
41
|
def user(self) -> Any | None:
|
|
47
42
|
"""Get the authenticated user for this request."""
|
|
@@ -84,7 +79,7 @@ class AuthViewMixin(SessionViewMixin):
|
|
|
84
79
|
# Show a 404 so we don't expose admin urls to non-admin users
|
|
85
80
|
raise Http404()
|
|
86
81
|
|
|
87
|
-
def get_response(self) ->
|
|
82
|
+
def get_response(self) -> ResponseBase:
|
|
88
83
|
try:
|
|
89
84
|
self.check_auth()
|
|
90
85
|
except LoginRequired as e:
|
|
@@ -110,8 +105,7 @@ class AuthViewMixin(SessionViewMixin):
|
|
|
110
105
|
else:
|
|
111
106
|
raise PermissionDenied("Login required")
|
|
112
107
|
|
|
113
|
-
|
|
114
|
-
response = super().get_response() # type: ignore[misc]
|
|
108
|
+
response = super().get_response()
|
|
115
109
|
|
|
116
110
|
if self.user:
|
|
117
111
|
# Make sure it at least has private as a default
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from plain.auth.views import
|
|
1
|
+
from plain.auth.views import AuthView
|
|
2
2
|
from plain.urls import Router, path
|
|
3
3
|
from plain.views import View
|
|
4
4
|
|
|
@@ -8,28 +8,28 @@ class LoginView(View):
|
|
|
8
8
|
return "login"
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
class ProtectedView(
|
|
11
|
+
class ProtectedView(AuthView):
|
|
12
12
|
login_required = True
|
|
13
13
|
|
|
14
14
|
def get(self):
|
|
15
15
|
return "protected"
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
class OpenView(
|
|
18
|
+
class OpenView(AuthView):
|
|
19
19
|
# login_required = False
|
|
20
20
|
|
|
21
21
|
def get(self):
|
|
22
22
|
return "open"
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
class AdminView(
|
|
25
|
+
class AdminView(AuthView):
|
|
26
26
|
admin_required = True
|
|
27
27
|
|
|
28
28
|
def get(self):
|
|
29
29
|
return "admin"
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
class NoLoginUrlView(
|
|
32
|
+
class NoLoginUrlView(AuthView):
|
|
33
33
|
login_required = True
|
|
34
34
|
login_url = None
|
|
35
35
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|