plain.auth 0.20.4__py3-none-any.whl → 0.20.6__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,25 @@
1
1
  # plain-auth changelog
2
2
 
3
+ ## [0.20.6](https://github.com/dropseed/plain/releases/plain-auth@0.20.6) (2025-10-22)
4
+
5
+ ### What's changed
6
+
7
+ - Fixed impersonation check in `AuthViewMixin` to properly handle optional `plain-admin` dependency using `get_request_impersonator()` function instead of `getattr()` ([548a385](https://github.com/dropseed/plain/commit/548a3859f5))
8
+
9
+ ### Upgrade instructions
10
+
11
+ - No changes required
12
+
13
+ ## [0.20.5](https://github.com/dropseed/plain/releases/plain-auth@0.20.5) (2025-10-20)
14
+
15
+ ### What's changed
16
+
17
+ - Updated `pyproject.toml` to use standard `[dependency-groups]` format instead of uv-specific `[tool.uv]` section for development dependencies ([1b43a3a](https://github.com/dropseed/plain/commit/1b43a3a272))
18
+
19
+ ### Upgrade instructions
20
+
21
+ - No changes required
22
+
3
23
  ## [0.20.4](https://github.com/dropseed/plain/releases/plain-auth@0.20.4) (2025-10-16)
4
24
 
5
25
  ### What's changed
plain/auth/views.py CHANGED
@@ -23,6 +23,11 @@ from .utils import resolve_url
23
23
  if TYPE_CHECKING:
24
24
  from plain.http import Request
25
25
 
26
+ try:
27
+ from plain.admin.impersonate import get_request_impersonator
28
+ except ImportError:
29
+ get_request_impersonator: Any = None
30
+
26
31
 
27
32
  class LoginRequired(Exception):
28
33
  def __init__(self, login_url: str | None = None, redirect_field_name: str = "next"):
@@ -65,14 +70,17 @@ class AuthViewMixin(SessionViewMixin):
65
70
  if self.admin_required:
66
71
  # At this point, we know user is authenticated (from check above)
67
72
  # Check if impersonation is active
68
- if impersonator := getattr(self, "impersonator", None):
69
- # Impersonators should be able to view admin pages while impersonating.
70
- # There's probably never a case where an impersonator isn't admin, but it can be configured.
71
- if not impersonator.is_admin:
72
- raise PermissionDenied(
73
- "You do not have permission to access this page."
74
- )
75
- elif not self.user.is_admin:
73
+ if get_request_impersonator:
74
+ if impersonator := get_request_impersonator(self.request):
75
+ # Impersonators should be able to view admin pages while impersonating.
76
+ # There's probably never a case where an impersonator isn't admin, but it can be configured.
77
+ if not impersonator.is_admin:
78
+ raise PermissionDenied(
79
+ "You do not have permission to access this page."
80
+ )
81
+ return
82
+
83
+ if not self.user.is_admin:
76
84
  # Show a 404 so we don't expose admin urls to non-admin users
77
85
  raise Http404()
78
86
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plain.auth
3
- Version: 0.20.4
3
+ Version: 0.20.6
4
4
  Summary: Add users to your app and decide what they can access.
5
5
  Author-email: Dave Gaeddert <dave.gaeddert@dropseed.dev>
6
6
  License-File: LICENSE
@@ -1,4 +1,4 @@
1
- plain/auth/CHANGELOG.md,sha256=ZVjrOfpSyQpusskFrqBy4zE6xkdwgxqtKp52p9C3OyU,5706
1
+ plain/auth/CHANGELOG.md,sha256=JtHcjYZy_Di1OCuCSduk91clMWnD5G4_2zEqSWpsypo,6463
2
2
  plain/auth/README.md,sha256=I1SeOyrBnF0GAjD7T0k5OlZ2bSHz9---nElinaobewc,4030
3
3
  plain/auth/__init__.py,sha256=CrOsS74CPGN1nPTTfie13mPgdyVLRyZ1YwDPIA77uaA,179
4
4
  plain/auth/default_settings.py,sha256=65VzDn3j61OMn78Lg6Zuds4A8QKzJJ_0G9KoFqAOIRo,466
@@ -7,8 +7,8 @@ plain/auth/sessions.py,sha256=xDp1EiB0cV5w3L5XioqO8vs77wnF8cvreExms3-e744,6015
7
7
  plain/auth/templates.py,sha256=CVtuIdBgOgYB2o61zpOPJb6nMx_gU61i_3PDQx8FjVs,770
8
8
  plain/auth/test.py,sha256=SHawhwarJEMVfaLkjpiuFVSWZoGIMwhzXreU_T1zvCE,1599
9
9
  plain/auth/utils.py,sha256=9kKWh1QqxA8Esct-jBvTCdjBYOHpO_Tg1YeV9WxYmxg,1362
10
- plain/auth/views.py,sha256=vWLMeykTrA5LtA179uE7w-BY9Kv25r1VScLHooDvZUA,4792
11
- plain_auth-0.20.4.dist-info/METADATA,sha256=LX7Mn95wVSOGa5ToCVmlJiukpgVARMIG9bPWYUtxf7A,4390
12
- plain_auth-0.20.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
13
- plain_auth-0.20.4.dist-info/licenses/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
14
- plain_auth-0.20.4.dist-info/RECORD,,
10
+ plain/auth/views.py,sha256=dGkPQpzPywqMDk3uDhmbAEVojMShhjwJj88f4ztmYmQ,5022
11
+ plain_auth-0.20.6.dist-info/METADATA,sha256=3lwbB0CqSJqpdGPHOUUgHAEssSwAc76wvZxT4sP4N-M,4390
12
+ plain_auth-0.20.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
13
+ plain_auth-0.20.6.dist-info/licenses/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
14
+ plain_auth-0.20.6.dist-info/RECORD,,