supabase_auth 2.9.3__tar.gz → 2.11.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.
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/PKG-INFO +1 -1
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/pyproject.toml +5 -5
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/supabase_auth/_sync/client.py +13 -1
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/supabase_auth/helpers.py +29 -0
- supabase_auth-2.11.0/supabase_auth/version.py +1 -0
- supabase_auth-2.9.3/supabase_auth/version.py +0 -1
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/LICENSE +0 -0
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/README.md +0 -0
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/supabase_auth/__init__.py +0 -0
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/supabase_auth/_async/__init__.py +0 -0
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/supabase_auth/_async/gotrue_admin_api.py +0 -0
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/supabase_auth/_async/gotrue_admin_mfa_api.py +0 -0
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/supabase_auth/_async/gotrue_base_api.py +0 -0
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/supabase_auth/_async/gotrue_client.py +0 -0
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/supabase_auth/_async/gotrue_mfa_api.py +0 -0
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/supabase_auth/_async/storage.py +0 -0
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/supabase_auth/_sync/__init__.py +0 -0
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/supabase_auth/_sync/api.py +0 -0
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/supabase_auth/_sync/gotrue_admin_api.py +0 -0
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/supabase_auth/_sync/gotrue_admin_mfa_api.py +0 -0
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/supabase_auth/_sync/gotrue_base_api.py +0 -0
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/supabase_auth/_sync/gotrue_client.py +0 -0
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/supabase_auth/_sync/gotrue_mfa_api.py +0 -0
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/supabase_auth/_sync/storage.py +0 -0
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/supabase_auth/constants.py +0 -0
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/supabase_auth/errors.py +0 -0
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/supabase_auth/http_clients.py +0 -0
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/supabase_auth/timer.py +0 -0
- {supabase_auth-2.9.3 → supabase_auth-2.11.0}/supabase_auth/types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "supabase_auth"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.11.0" # {x-release-please-version}
|
|
4
4
|
description = "Python Client Library for Supabase Auth"
|
|
5
5
|
authors = ["Joel Lee <joel@joellee.org>"]
|
|
6
6
|
homepage = "https://github.com/supabase/auth-py"
|
|
@@ -21,14 +21,14 @@ pydantic = ">=1.10,<3"
|
|
|
21
21
|
|
|
22
22
|
[tool.poetry.dev-dependencies]
|
|
23
23
|
pytest = "^8.3.3"
|
|
24
|
-
flake8 = "^
|
|
24
|
+
flake8 = "^7.1.1"
|
|
25
25
|
black = "^24.4.2"
|
|
26
26
|
isort = "^5.12.0"
|
|
27
|
-
pre-commit = "^
|
|
28
|
-
pytest-cov = "^
|
|
27
|
+
pre-commit = "^4.0.1"
|
|
28
|
+
pytest-cov = "^6.0.0"
|
|
29
29
|
pytest-depends = "^1.0.1"
|
|
30
30
|
pytest-asyncio = "^0.24.0"
|
|
31
|
-
Faker = "^
|
|
31
|
+
Faker = "^33.0.0"
|
|
32
32
|
unasync-cli = "^0.0.9"
|
|
33
33
|
|
|
34
34
|
[tool.poetry.group.dev.dependencies]
|
|
@@ -10,7 +10,7 @@ from uuid import uuid4
|
|
|
10
10
|
|
|
11
11
|
from ..constants import COOKIE_OPTIONS, DEFAULT_HEADERS, GOTRUE_URL, STORAGE_KEY
|
|
12
12
|
from ..exceptions import APIError
|
|
13
|
-
from ..helpers import model_dump, model_validate
|
|
13
|
+
from ..helpers import is_http_url, is_valid_jwt, model_dump, model_validate
|
|
14
14
|
from ..types import (
|
|
15
15
|
AuthChangeEvent,
|
|
16
16
|
CookieOptions,
|
|
@@ -61,6 +61,8 @@ class SyncGoTrueClient:
|
|
|
61
61
|
proxy: str
|
|
62
62
|
HTTP Proxy string or None, None by default, None disables proxy.
|
|
63
63
|
"""
|
|
64
|
+
if not is_http_url(url):
|
|
65
|
+
ValueError("url must be a valid HTTP URL string")
|
|
64
66
|
if url.startswith("http://"):
|
|
65
67
|
print(
|
|
66
68
|
"Warning:\n\nDO NOT USE HTTP IN PRODUCTION FOR GOTRUE EVER!\n"
|
|
@@ -362,6 +364,10 @@ class SyncGoTrueClient:
|
|
|
362
364
|
APIError
|
|
363
365
|
If an error occurs.
|
|
364
366
|
"""
|
|
367
|
+
|
|
368
|
+
if not is_valid_jwt(refresh_token):
|
|
369
|
+
ValueError("refresh_token must be a valid JWT authorization token")
|
|
370
|
+
|
|
365
371
|
response = self.api.refresh_access_token(refresh_token=refresh_token)
|
|
366
372
|
self._save_session(session=response)
|
|
367
373
|
self._notify_all_subscribers(event=AuthChangeEvent.SIGNED_IN)
|
|
@@ -386,6 +392,10 @@ class SyncGoTrueClient:
|
|
|
386
392
|
APIError
|
|
387
393
|
If an error occurs.
|
|
388
394
|
"""
|
|
395
|
+
|
|
396
|
+
if not is_valid_jwt(access_token):
|
|
397
|
+
ValueError("access_token must be a valid JWT authorization token")
|
|
398
|
+
|
|
389
399
|
session = Session(
|
|
390
400
|
access_token=access_token,
|
|
391
401
|
token_type="bearer",
|
|
@@ -428,6 +438,8 @@ class SyncGoTrueClient:
|
|
|
428
438
|
APIError
|
|
429
439
|
If an error occurs.
|
|
430
440
|
"""
|
|
441
|
+
if not is_http_url(url):
|
|
442
|
+
ValueError("url must be a valid HTTP URL string")
|
|
431
443
|
data = urlparse(url)
|
|
432
444
|
query = parse_qs(data.query)
|
|
433
445
|
error_description = query.get("error_description")
|
|
@@ -9,6 +9,7 @@ from base64 import urlsafe_b64decode
|
|
|
9
9
|
from datetime import datetime
|
|
10
10
|
from json import loads
|
|
11
11
|
from typing import Any, Dict, Optional, Type, TypeVar, cast
|
|
12
|
+
from urllib.parse import urlparse
|
|
12
13
|
|
|
13
14
|
from httpx import HTTPStatusError, Response
|
|
14
15
|
from pydantic import BaseModel
|
|
@@ -34,6 +35,7 @@ from .types import (
|
|
|
34
35
|
)
|
|
35
36
|
|
|
36
37
|
TBaseModel = TypeVar("TBaseModel", bound=BaseModel)
|
|
38
|
+
BASE64URL_REGEX = r"^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$"
|
|
37
39
|
|
|
38
40
|
|
|
39
41
|
def model_validate(model: Type[TBaseModel], contents) -> TBaseModel:
|
|
@@ -238,3 +240,30 @@ def parse_response_api_version(response: Response):
|
|
|
238
240
|
return dt
|
|
239
241
|
except Exception as e:
|
|
240
242
|
return None
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
def is_http_url(url: str) -> bool:
|
|
246
|
+
return urlparse(url).scheme in {"https", "http"}
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def is_valid_jwt(value: str) -> bool:
|
|
250
|
+
"""Checks if value looks like a JWT, does not do any extra parsing."""
|
|
251
|
+
if not isinstance(value, str):
|
|
252
|
+
return False
|
|
253
|
+
|
|
254
|
+
# Remove trailing whitespaces if any.
|
|
255
|
+
value = value.strip()
|
|
256
|
+
|
|
257
|
+
# Remove "Bearer " prefix if any.
|
|
258
|
+
if value.startswith("Bearer "):
|
|
259
|
+
value = value[7:]
|
|
260
|
+
|
|
261
|
+
# Valid JWT must have 2 dots (Header.Paylod.Signature)
|
|
262
|
+
if value.count(".") != 2:
|
|
263
|
+
return False
|
|
264
|
+
|
|
265
|
+
for part in value.split("."):
|
|
266
|
+
if not re.search(BASE64URL_REGEX, part, re.IGNORECASE):
|
|
267
|
+
return False
|
|
268
|
+
|
|
269
|
+
return True
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.11.0" # {x-release-please-version}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "2.9.3" # {x-release-please-version}
|
|
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
|
|
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
|