plain.oauth 0.29.2__py3-none-any.whl → 0.31.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 CHANGED
@@ -1,5 +1,26 @@
1
1
  # plain-oauth changelog
2
2
 
3
+ ## [0.31.0](https://github.com/dropseed/plain/releases/plain-oauth@0.31.0) (2025-10-12)
4
+
5
+ ### What's changed
6
+
7
+ - Preflight provider key check has been moved from the model to a standalone `CheckOAuthProviderKeys` preflight check class ([fdc5aee](https://github.com/dropseed/plain/commit/fdc5aee))
8
+ - Preflight check ID has been renamed from `oauth.provider_in_db_not_in_settings` to `oauth.provider_settings_missing` ([fdc5aee](https://github.com/dropseed/plain/commit/fdc5aee))
9
+
10
+ ### Upgrade instructions
11
+
12
+ - No changes required
13
+
14
+ ## [0.30.0](https://github.com/dropseed/plain/releases/plain-oauth@0.30.0) (2025-10-07)
15
+
16
+ ### What's changed
17
+
18
+ - 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))
19
+
20
+ ### Upgrade instructions
21
+
22
+ - No changes required
23
+
3
24
  ## [0.29.2](https://github.com/dropseed/plain/releases/plain-oauth@0.29.2) (2025-10-06)
4
25
 
5
26
  ### What's changed
plain/oauth/models.py CHANGED
@@ -4,8 +4,7 @@ from plain import models
4
4
  from plain.auth import get_user_model
5
5
  from plain.exceptions import ValidationError
6
6
  from plain.models import transaction
7
- from plain.models.db import IntegrityError, OperationalError, ProgrammingError
8
- from plain.preflight import PreflightResult
7
+ from plain.models.db import IntegrityError
9
8
  from plain.runtime import SettingsReference
10
9
  from plain.utils import timezone
11
10
 
@@ -15,9 +14,6 @@ if TYPE_CHECKING:
15
14
  from .providers import OAuthToken, OAuthUser
16
15
 
17
16
 
18
- # TODO preflight check for deploy that ensures all provider keys in db are also in settings?
19
-
20
-
21
17
  @models.register_model
22
18
  class OAuthConnection(models.Model):
23
19
  created_at = models.DateTimeField(auto_now_add=True)
@@ -41,14 +37,15 @@ class OAuthConnection(models.Model):
41
37
  access_token_expires_at = models.DateTimeField(required=False, allow_null=True)
42
38
  refresh_token_expires_at = models.DateTimeField(required=False, allow_null=True)
43
39
 
44
- class Meta:
45
- constraints = [
40
+ model_options = models.Options(
41
+ constraints=[
46
42
  models.UniqueConstraint(
47
43
  fields=["provider_key", "provider_user_id"],
48
44
  name="plainoauth_oauthconnection_unique_provider_key_user_id",
49
45
  )
50
- ]
51
- ordering = ("provider_key",)
46
+ ],
47
+ ordering=("provider_key",),
48
+ )
52
49
 
53
50
  def __str__(self) -> str:
54
51
  return f"{self.provider_key}[{self.user}:{self.provider_user_id}]"
@@ -153,35 +150,3 @@ class OAuthConnection(models.Model):
153
150
  connection.save()
154
151
 
155
152
  return connection
156
-
157
- @classmethod
158
- def preflight(cls) -> list[PreflightResult]:
159
- """
160
- A system check for ensuring that provider_keys in the database are also present in settings.
161
- """
162
- errors = super().preflight()
163
-
164
- from .providers import get_provider_keys
165
-
166
- try:
167
- keys_in_db = set(
168
- cls.query.values_list("provider_key", flat=True).distinct()
169
- )
170
- except (OperationalError, ProgrammingError):
171
- # Check runs on plain migrate, and the table may not exist yet
172
- # or it may not be installed on the particular database intentionally
173
- return errors
174
-
175
- keys_in_settings = set(get_provider_keys())
176
-
177
- if keys_in_db - keys_in_settings:
178
- errors.append(
179
- PreflightResult(
180
- fix="The following OAuth providers are in the database but not in the settings: {}. Add these providers to your OAUTH_LOGIN_PROVIDERS setting or remove the corresponding OAuthConnection records.".format(
181
- ", ".join(keys_in_db - keys_in_settings)
182
- ),
183
- id="oauth.provider_in_db_not_in_settings",
184
- )
185
- )
186
-
187
- return errors
@@ -0,0 +1,38 @@
1
+ from plain.models import OperationalError, ProgrammingError
2
+ from plain.preflight import PreflightCheck, PreflightResult, register_check
3
+
4
+
5
+ @register_check(name="oauth.provider_keys")
6
+ class CheckOAuthProviderKeys(PreflightCheck):
7
+ """
8
+ Check for OAuth provider keys in the database that are not present in settings.
9
+ """
10
+
11
+ def run(self) -> list[PreflightResult]:
12
+ from .models import OAuthConnection
13
+ from .providers import get_provider_keys
14
+
15
+ errors = []
16
+
17
+ try:
18
+ keys_in_db = set(
19
+ OAuthConnection.query.values_list("provider_key", flat=True).distinct()
20
+ )
21
+ except (OperationalError, ProgrammingError):
22
+ # Check runs on plain migrate, and the table may not exist yet
23
+ # or it may not be installed on the particular database intentionally
24
+ return errors
25
+
26
+ keys_in_settings = set(get_provider_keys())
27
+
28
+ if keys_in_db - keys_in_settings:
29
+ errors.append(
30
+ PreflightResult(
31
+ fix="The following OAuth providers are in the database but not in the settings: {}. Add these providers to your OAUTH_LOGIN_PROVIDERS setting or remove the corresponding OAuthConnection records.".format(
32
+ ", ".join(keys_in_db - keys_in_settings)
33
+ ),
34
+ id="oauth.provider_settings_missing",
35
+ )
36
+ )
37
+
38
+ return errors
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plain.oauth
3
- Version: 0.29.2
3
+ Version: 0.31.0
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
@@ -1,18 +1,19 @@
1
- plain/oauth/CHANGELOG.md,sha256=qylweVHAeginfzazOVY53pbo_Ug0KZ_fATie7RPI9D0,6416
1
+ plain/oauth/CHANGELOG.md,sha256=2I9p3OVtBSMC9ayj2DGQvX2QLjtVbitf6URsIhYHSXE,7324
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=dIlRzRCAAU3gy46ks8bkV9JkznuMNreC3avkKcUTicU,6726
8
+ plain/oauth/models.py,sha256=Eo5a93RMnsLuAFJjVyPo6xtAtqWErEdK7RuOruvb6kA,5340
9
+ plain/oauth/preflight.py,sha256=KN-sBlXaBelLTct2fHc--JmDeyCSWX_rrXCgRHTrWMQ,1450
9
10
  plain/oauth/providers.py,sha256=I9YAZgvkueFZb0fquhF85qNQDnZMkuTgj1YuVPiPUno,7961
10
11
  plain/oauth/urls.py,sha256=FYzpQwhvZdcat8n3f7RyA-1Q21finKb8JEyakSOjXXg,696
11
12
  plain/oauth/views.py,sha256=_u4qIo4DtZ6x1YH3Byhh20sC4ZwVGlIXcLwWBzSFPxI,2530
12
13
  plain/oauth/migrations/0001_initial.py,sha256=0NjfF7F3szhUXkpK3JvN10Xkat1QR-VvnX6Oed9iFmo,1940
13
14
  plain/oauth/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
15
  plain/oauth/templates/oauth/callback.html,sha256=4CJG0oAN0xYjw2IPkjaL7B4hwlf9um9LI4CTu50E-yE,173
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,,
16
+ plain_oauth-0.31.0.dist-info/METADATA,sha256=pMfJXRIIzxjqBmnRUate_TswbZbMUZqvmtwFqU2Ap6E,11494
17
+ plain_oauth-0.31.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
+ plain_oauth-0.31.0.dist-info/licenses/LICENSE,sha256=cvKM3OlqHx3ijD6e34zsSUkPvzl-ya3Dd63A6EHL94U,1500
19
+ plain_oauth-0.31.0.dist-info/RECORD,,