plain.oauth 0.29.1__py3-none-any.whl → 0.30.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/oauth/CHANGELOG.md +21 -0
- plain/oauth/models.py +11 -10
- plain/oauth/providers.py +1 -1
- plain/oauth/views.py +5 -5
- {plain_oauth-0.29.1.dist-info → plain_oauth-0.30.0.dist-info}/METADATA +1 -1
- {plain_oauth-0.29.1.dist-info → plain_oauth-0.30.0.dist-info}/RECORD +8 -8
- {plain_oauth-0.29.1.dist-info → plain_oauth-0.30.0.dist-info}/WHEEL +0 -0
- {plain_oauth-0.29.1.dist-info → plain_oauth-0.30.0.dist-info}/licenses/LICENSE +0 -0
plain/oauth/CHANGELOG.md
CHANGED
@@ -1,5 +1,26 @@
|
|
1
1
|
# plain-oauth changelog
|
2
2
|
|
3
|
+
## [0.30.0](https://github.com/dropseed/plain/releases/plain-oauth@0.30.0) (2025-10-07)
|
4
|
+
|
5
|
+
### What's changed
|
6
|
+
|
7
|
+
- Model metadata is now defined using `model_options = models.Options(...)` instead of `class Meta` ([17a378d](https://github.com/dropseed/plain/commit/17a378d), [73ba469](https://github.com/dropseed/plain/commit/73ba469))
|
8
|
+
|
9
|
+
### Upgrade instructions
|
10
|
+
|
11
|
+
- No changes required
|
12
|
+
|
13
|
+
## [0.29.2](https://github.com/dropseed/plain/releases/plain-oauth@0.29.2) (2025-10-06)
|
14
|
+
|
15
|
+
### What's changed
|
16
|
+
|
17
|
+
- Added type annotations to improve IDE and type checker friendliness ([35fb8c4](https://github.com/dropseed/plain/commit/35fb8c4))
|
18
|
+
- Updated provider examples (Bitbucket, GitHub, GitLab) with proper type annotations ([50463b0](https://github.com/dropseed/plain/commit/50463b0))
|
19
|
+
|
20
|
+
### Upgrade instructions
|
21
|
+
|
22
|
+
- No changes required
|
23
|
+
|
3
24
|
## [0.29.1](https://github.com/dropseed/plain/releases/plain-oauth@0.29.1) (2025-10-02)
|
4
25
|
|
5
26
|
### What's changed
|
plain/oauth/models.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import TYPE_CHECKING
|
1
|
+
from typing import TYPE_CHECKING, Any
|
2
2
|
|
3
3
|
from plain import models
|
4
4
|
from plain.auth import get_user_model
|
@@ -41,16 +41,17 @@ class OAuthConnection(models.Model):
|
|
41
41
|
access_token_expires_at = models.DateTimeField(required=False, allow_null=True)
|
42
42
|
refresh_token_expires_at = models.DateTimeField(required=False, allow_null=True)
|
43
43
|
|
44
|
-
|
45
|
-
constraints
|
44
|
+
model_options = models.Options(
|
45
|
+
constraints=[
|
46
46
|
models.UniqueConstraint(
|
47
47
|
fields=["provider_key", "provider_user_id"],
|
48
48
|
name="plainoauth_oauthconnection_unique_provider_key_user_id",
|
49
49
|
)
|
50
|
-
]
|
51
|
-
ordering
|
50
|
+
],
|
51
|
+
ordering=("provider_key",),
|
52
|
+
)
|
52
53
|
|
53
|
-
def __str__(self):
|
54
|
+
def __str__(self) -> str:
|
54
55
|
return f"{self.provider_key}[{self.user}:{self.provider_user_id}]"
|
55
56
|
|
56
57
|
def refresh_access_token(self) -> None:
|
@@ -69,13 +70,13 @@ class OAuthConnection(models.Model):
|
|
69
70
|
self.set_token_fields(refreshed_oauth_token)
|
70
71
|
self.save()
|
71
72
|
|
72
|
-
def set_token_fields(self, oauth_token: "OAuthToken"):
|
73
|
+
def set_token_fields(self, oauth_token: "OAuthToken") -> None:
|
73
74
|
self.access_token = oauth_token.access_token
|
74
75
|
self.refresh_token = oauth_token.refresh_token
|
75
76
|
self.access_token_expires_at = oauth_token.access_token_expires_at
|
76
77
|
self.refresh_token_expires_at = oauth_token.refresh_token_expires_at
|
77
78
|
|
78
|
-
def set_user_fields(self, oauth_user: "OAuthUser"):
|
79
|
+
def set_user_fields(self, oauth_user: "OAuthUser") -> None:
|
79
80
|
self.provider_user_id = oauth_user.provider_id
|
80
81
|
|
81
82
|
def access_token_expired(self) -> bool:
|
@@ -125,7 +126,7 @@ class OAuthConnection(models.Model):
|
|
125
126
|
def connect(
|
126
127
|
cls,
|
127
128
|
*,
|
128
|
-
user,
|
129
|
+
user: Any,
|
129
130
|
provider_key: str,
|
130
131
|
oauth_token: "OAuthToken",
|
131
132
|
oauth_user: "OAuthUser",
|
@@ -155,7 +156,7 @@ class OAuthConnection(models.Model):
|
|
155
156
|
return connection
|
156
157
|
|
157
158
|
@classmethod
|
158
|
-
def preflight(cls):
|
159
|
+
def preflight(cls) -> list[PreflightResult]:
|
159
160
|
"""
|
160
161
|
A system check for ensuring that provider_keys in the database are also present in settings.
|
161
162
|
"""
|
plain/oauth/providers.py
CHANGED
@@ -40,7 +40,7 @@ class OAuthUser:
|
|
40
40
|
self.provider_id = provider_id # ID on the provider's system
|
41
41
|
self.user_model_fields = user_model_fields or {}
|
42
42
|
|
43
|
-
def __str__(self):
|
43
|
+
def __str__(self) -> str:
|
44
44
|
if "email" in self.user_model_fields:
|
45
45
|
return self.user_model_fields["email"]
|
46
46
|
if "username" in self.user_model_fields:
|
plain/oauth/views.py
CHANGED
@@ -2,7 +2,7 @@ import logging
|
|
2
2
|
|
3
3
|
from plain.auth.requests import get_request_user
|
4
4
|
from plain.auth.views import AuthViewMixin
|
5
|
-
from plain.http import ResponseRedirect
|
5
|
+
from plain.http import Response, ResponseRedirect
|
6
6
|
from plain.views import TemplateView, View
|
7
7
|
|
8
8
|
from .exceptions import (
|
@@ -14,7 +14,7 @@ logger = logging.getLogger(__name__)
|
|
14
14
|
|
15
15
|
|
16
16
|
class OAuthLoginView(View):
|
17
|
-
def post(self):
|
17
|
+
def post(self) -> Response:
|
18
18
|
request = self.request
|
19
19
|
provider = self.url_kwargs["provider"]
|
20
20
|
if get_request_user(request):
|
@@ -31,7 +31,7 @@ class OAuthCallbackView(TemplateView):
|
|
31
31
|
|
32
32
|
template_name = "oauth/callback.html"
|
33
33
|
|
34
|
-
def get(self):
|
34
|
+
def get(self) -> Response:
|
35
35
|
provider = self.url_kwargs["provider"]
|
36
36
|
provider_instance = get_oauth_provider_instance(provider_key=provider)
|
37
37
|
try:
|
@@ -51,7 +51,7 @@ class OAuthCallbackView(TemplateView):
|
|
51
51
|
|
52
52
|
|
53
53
|
class OAuthConnectView(AuthViewMixin, View):
|
54
|
-
def post(self):
|
54
|
+
def post(self) -> Response:
|
55
55
|
request = self.request
|
56
56
|
provider = self.url_kwargs["provider"]
|
57
57
|
provider_instance = get_oauth_provider_instance(provider_key=provider)
|
@@ -59,7 +59,7 @@ class OAuthConnectView(AuthViewMixin, View):
|
|
59
59
|
|
60
60
|
|
61
61
|
class OAuthDisconnectView(AuthViewMixin, View):
|
62
|
-
def post(self):
|
62
|
+
def post(self) -> Response:
|
63
63
|
request = self.request
|
64
64
|
provider = self.url_kwargs["provider"]
|
65
65
|
provider_instance = get_oauth_provider_instance(provider_key=provider)
|
@@ -1,18 +1,18 @@
|
|
1
|
-
plain/oauth/CHANGELOG.md,sha256=
|
1
|
+
plain/oauth/CHANGELOG.md,sha256=Mruypow7ThQ_Q6s4AytvZrs05E3acN-UEphJ0Q3HrX4,6798
|
2
2
|
plain/oauth/README.md,sha256=5wWECig99tV7g5Hkqmd0ClSH0KpXgu0TRBkY0c_dH3o,11089
|
3
3
|
plain/oauth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
4
|
plain/oauth/admin.py,sha256=s259OnTWGeOv3nVl4hAV-lNAIE4d2ObbG_97ENC6TuY,1308
|
5
5
|
plain/oauth/config.py,sha256=0Q4IILBKQbIaxqeL9WRTH5Cka-BO3c3SOj1AdQIAJgc,167
|
6
6
|
plain/oauth/default_settings.py,sha256=dlN1J9vSOjjxPNLp-0qe-cLTqwM4E69ZAx_8lpxMhaM,28
|
7
7
|
plain/oauth/exceptions.py,sha256=yoZsq8XgzstuwbE2ihoet0nzpw_sVZgDrwUauh6hhUs,546
|
8
|
-
plain/oauth/models.py,sha256=
|
9
|
-
plain/oauth/providers.py,sha256=
|
8
|
+
plain/oauth/models.py,sha256=LXeFnrKM7jWGBUu3A2zfd0YFjYOVjRNUqvtGyU9PugY,6750
|
9
|
+
plain/oauth/providers.py,sha256=I9YAZgvkueFZb0fquhF85qNQDnZMkuTgj1YuVPiPUno,7961
|
10
10
|
plain/oauth/urls.py,sha256=FYzpQwhvZdcat8n3f7RyA-1Q21finKb8JEyakSOjXXg,696
|
11
|
-
plain/oauth/views.py,sha256=
|
11
|
+
plain/oauth/views.py,sha256=_u4qIo4DtZ6x1YH3Byhh20sC4ZwVGlIXcLwWBzSFPxI,2530
|
12
12
|
plain/oauth/migrations/0001_initial.py,sha256=0NjfF7F3szhUXkpK3JvN10Xkat1QR-VvnX6Oed9iFmo,1940
|
13
13
|
plain/oauth/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
14
14
|
plain/oauth/templates/oauth/callback.html,sha256=4CJG0oAN0xYjw2IPkjaL7B4hwlf9um9LI4CTu50E-yE,173
|
15
|
-
plain_oauth-0.
|
16
|
-
plain_oauth-0.
|
17
|
-
plain_oauth-0.
|
18
|
-
plain_oauth-0.
|
15
|
+
plain_oauth-0.30.0.dist-info/METADATA,sha256=rTmYmD1-sCoMstQY8YWuEr-49v-2KNg_G4jc01_0BuQ,11494
|
16
|
+
plain_oauth-0.30.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
17
|
+
plain_oauth-0.30.0.dist-info/licenses/LICENSE,sha256=cvKM3OlqHx3ijD6e34zsSUkPvzl-ya3Dd63A6EHL94U,1500
|
18
|
+
plain_oauth-0.30.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|