plain.oauth 0.29.0__py3-none-any.whl → 0.29.2__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 CHANGED
@@ -1,5 +1,26 @@
1
1
  # plain-oauth changelog
2
2
 
3
+ ## [0.29.2](https://github.com/dropseed/plain/releases/plain-oauth@0.29.2) (2025-10-06)
4
+
5
+ ### What's changed
6
+
7
+ - Added type annotations to improve IDE and type checker friendliness ([35fb8c4](https://github.com/dropseed/plain/commit/35fb8c4))
8
+ - Updated provider examples (Bitbucket, GitHub, GitLab) with proper type annotations ([50463b0](https://github.com/dropseed/plain/commit/50463b0))
9
+
10
+ ### Upgrade instructions
11
+
12
+ - No changes required
13
+
14
+ ## [0.29.1](https://github.com/dropseed/plain/releases/plain-oauth@0.29.1) (2025-10-02)
15
+
16
+ ### What's changed
17
+
18
+ - Updated documentation examples to use `get_current_user()` instead of `request.user` ([f6278d9](https://github.com/dropseed/plain/commit/f6278d9bb4))
19
+
20
+ ### Upgrade instructions
21
+
22
+ - No changes required
23
+
3
24
  ## [0.29.0](https://github.com/dropseed/plain/releases/plain-oauth@0.29.0) (2025-10-02)
4
25
 
5
26
  ### What's changed
plain/oauth/README.md CHANGED
@@ -182,11 +182,11 @@ Here's an very basic example:
182
182
  {% extends "base.html" %}
183
183
 
184
184
  {% block content %}
185
- Hello {{ request.user }}!
185
+ Hello {{ get_current_user() }}!
186
186
 
187
187
  <h2>Existing connections</h2>
188
188
  <ul>
189
- {% for connection in request.user.oauth_connections.all %}
189
+ {% for connection in get_current_user().oauth_connections.all %}
190
190
  <li>
191
191
  {{ connection.provider_key }} [ID: {{ connection.provider_user_id }}]
192
192
  <form action="{% url 'oauth:disconnect' connection.provider_key %}" method="post">
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
@@ -50,7 +50,7 @@ class OAuthConnection(models.Model):
50
50
  ]
51
51
  ordering = ("provider_key",)
52
52
 
53
- def __str__(self):
53
+ def __str__(self) -> str:
54
54
  return f"{self.provider_key}[{self.user}:{self.provider_user_id}]"
55
55
 
56
56
  def refresh_access_token(self) -> None:
@@ -69,13 +69,13 @@ class OAuthConnection(models.Model):
69
69
  self.set_token_fields(refreshed_oauth_token)
70
70
  self.save()
71
71
 
72
- def set_token_fields(self, oauth_token: "OAuthToken"):
72
+ def set_token_fields(self, oauth_token: "OAuthToken") -> None:
73
73
  self.access_token = oauth_token.access_token
74
74
  self.refresh_token = oauth_token.refresh_token
75
75
  self.access_token_expires_at = oauth_token.access_token_expires_at
76
76
  self.refresh_token_expires_at = oauth_token.refresh_token_expires_at
77
77
 
78
- def set_user_fields(self, oauth_user: "OAuthUser"):
78
+ def set_user_fields(self, oauth_user: "OAuthUser") -> None:
79
79
  self.provider_user_id = oauth_user.provider_id
80
80
 
81
81
  def access_token_expired(self) -> bool:
@@ -125,7 +125,7 @@ class OAuthConnection(models.Model):
125
125
  def connect(
126
126
  cls,
127
127
  *,
128
- user,
128
+ user: Any,
129
129
  provider_key: str,
130
130
  oauth_token: "OAuthToken",
131
131
  oauth_user: "OAuthUser",
@@ -155,7 +155,7 @@ class OAuthConnection(models.Model):
155
155
  return connection
156
156
 
157
157
  @classmethod
158
- def preflight(cls):
158
+ def preflight(cls) -> list[PreflightResult]:
159
159
  """
160
160
  A system check for ensuring that provider_keys in the database are also present in settings.
161
161
  """
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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plain.oauth
3
- Version: 0.29.0
3
+ Version: 0.29.2
4
4
  Summary: Let users log in with OAuth providers.
5
5
  Author-email: Dave Gaeddert <dave.gaeddert@dropseed.dev>
6
6
  License-Expression: BSD-3-Clause
@@ -196,11 +196,11 @@ Here's an very basic example:
196
196
  {% extends "base.html" %}
197
197
 
198
198
  {% block content %}
199
- Hello {{ request.user }}!
199
+ Hello {{ get_current_user() }}!
200
200
 
201
201
  <h2>Existing connections</h2>
202
202
  <ul>
203
- {% for connection in request.user.oauth_connections.all %}
203
+ {% for connection in get_current_user().oauth_connections.all %}
204
204
  <li>
205
205
  {{ connection.provider_key }} [ID: {{ connection.provider_user_id }}]
206
206
  <form action="{% url 'oauth:disconnect' connection.provider_key %}" method="post">
@@ -1,18 +1,18 @@
1
- plain/oauth/CHANGELOG.md,sha256=qdYHdliRCnHcenmsZ_xHntdUmDg4A-b14Y1hCrjorTQ,5667
2
- plain/oauth/README.md,sha256=m3RRb01DLnoxBtzuYzESSe49OmsZ8P1R5_QsfCSRQgo,11077
1
+ plain/oauth/CHANGELOG.md,sha256=qylweVHAeginfzazOVY53pbo_Ug0KZ_fATie7RPI9D0,6416
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=BKeJrfm93E1W5Zzf7z41hk0WvJe6p-EjZcZavmkGkRs,6668
9
- plain/oauth/providers.py,sha256=koT6Ohp9wMG7hjXrncCJV07HwrSs-NZ2yVmsgVo_-1s,7954
8
+ plain/oauth/models.py,sha256=dIlRzRCAAU3gy46ks8bkV9JkznuMNreC3avkKcUTicU,6726
9
+ plain/oauth/providers.py,sha256=I9YAZgvkueFZb0fquhF85qNQDnZMkuTgj1YuVPiPUno,7961
10
10
  plain/oauth/urls.py,sha256=FYzpQwhvZdcat8n3f7RyA-1Q21finKb8JEyakSOjXXg,696
11
- plain/oauth/views.py,sha256=LO7raeMkUrV9epVzIe6wNML3a22MDW41eeGDVPZIhM8,2472
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.29.0.dist-info/METADATA,sha256=Ht_lap9gWq1mEoDO8zDdCoqpkhKi1CLXpoG9H5t2eGg,11482
16
- plain_oauth-0.29.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
17
- plain_oauth-0.29.0.dist-info/licenses/LICENSE,sha256=cvKM3OlqHx3ijD6e34zsSUkPvzl-ya3Dd63A6EHL94U,1500
18
- plain_oauth-0.29.0.dist-info/RECORD,,
15
+ plain_oauth-0.29.2.dist-info/METADATA,sha256=V4-MnVxCLd-I3XpkFRggr8mNvKAJ2wxwptm1YPJu_BI,11494
16
+ plain_oauth-0.29.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
17
+ plain_oauth-0.29.2.dist-info/licenses/LICENSE,sha256=cvKM3OlqHx3ijD6e34zsSUkPvzl-ya3Dd63A6EHL94U,1500
18
+ plain_oauth-0.29.2.dist-info/RECORD,,