auth0-server-python 1.0.0b4__tar.gz → 1.0.0b6__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.
Files changed (21) hide show
  1. {auth0_server_python-1.0.0b4 → auth0_server_python-1.0.0b6}/PKG-INFO +12 -6
  2. {auth0_server_python-1.0.0b4 → auth0_server_python-1.0.0b6}/README.md +8 -5
  3. {auth0_server_python-1.0.0b4 → auth0_server_python-1.0.0b6}/pyproject.toml +3 -2
  4. auth0_server_python-1.0.0b6/src/auth0_server_python/auth_schemes/__init__.py +3 -0
  5. auth0_server_python-1.0.0b6/src/auth0_server_python/auth_schemes/bearer_auth.py +10 -0
  6. auth0_server_python-1.0.0b6/src/auth0_server_python/auth_server/__init__.py +4 -0
  7. auth0_server_python-1.0.0b6/src/auth0_server_python/auth_server/my_account_client.py +94 -0
  8. {auth0_server_python-1.0.0b4 → auth0_server_python-1.0.0b6}/src/auth0_server_python/auth_server/server_client.py +458 -140
  9. {auth0_server_python-1.0.0b4 → auth0_server_python-1.0.0b6}/src/auth0_server_python/auth_types/__init__.py +63 -31
  10. auth0_server_python-1.0.0b6/src/auth0_server_python/encryption/__init__.py +3 -0
  11. {auth0_server_python-1.0.0b4 → auth0_server_python-1.0.0b6}/src/auth0_server_python/encryption/encrypt.py +10 -11
  12. {auth0_server_python-1.0.0b4 → auth0_server_python-1.0.0b6}/src/auth0_server_python/error/__init__.py +48 -12
  13. {auth0_server_python-1.0.0b4 → auth0_server_python-1.0.0b6}/src/auth0_server_python/store/__init__.py +3 -3
  14. {auth0_server_python-1.0.0b4 → auth0_server_python-1.0.0b6}/src/auth0_server_python/store/abstract.py +29 -29
  15. auth0_server_python-1.0.0b6/src/auth0_server_python/tests/test_my_account_client.py +160 -0
  16. auth0_server_python-1.0.0b6/src/auth0_server_python/tests/test_server_client.py +1934 -0
  17. {auth0_server_python-1.0.0b4 → auth0_server_python-1.0.0b6}/src/auth0_server_python/utils/__init__.py +3 -2
  18. {auth0_server_python-1.0.0b4 → auth0_server_python-1.0.0b6}/src/auth0_server_python/utils/helpers.py +39 -38
  19. auth0_server_python-1.0.0b4/src/auth0_server_python/auth_server/__init__.py +0 -4
  20. auth0_server_python-1.0.0b4/src/auth0_server_python/encryption/__init__.py +0 -4
  21. {auth0_server_python-1.0.0b4 → auth0_server_python-1.0.0b6}/LICENSE +0 -0
@@ -1,8 +1,9 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: auth0-server-python
3
- Version: 1.0.0b4
3
+ Version: 1.0.0b6
4
4
  Summary: Auth0 server-side Python SDK
5
5
  License: MIT
6
+ License-File: LICENSE
6
7
  Author: Auth0
7
8
  Author-email: support@okta.com
8
9
  Requires-Python: >=3.9
@@ -13,6 +14,7 @@ Classifier: Programming Language :: Python :: 3.10
13
14
  Classifier: Programming Language :: Python :: 3.11
14
15
  Classifier: Programming Language :: Python :: 3.12
15
16
  Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
16
18
  Requires-Dist: authlib (>=1.2,<2.0)
17
19
  Requires-Dist: cryptography (>=43.0.1)
18
20
  Requires-Dist: httpx (>=0.28.1,<0.29.0)
@@ -23,13 +25,16 @@ Description-Content-Type: text/markdown
23
25
 
24
26
  The Auth0 Server Python SDK is a library for implementing user authentication in Python applications.
25
27
 
26
- ![PyPI](https://img.shields.io/pypi/v/auth0-server-python) ![Downloads](https://img.shields.io/pypi/dw/auth0-server-python) [![License](https://img.shields.io/:license-MIT-blue.svg?style=flat)](https://opensource.org/licenses/MIT)
28
+ ![PyPI](https://img.shields.io/pypi/v/auth0-server-python)
29
+ ![Downloads](https://img.shields.io/pypi/dw/auth0-server-python)
30
+ [![License](https://img.shields.io/:license-MIT-blue.svg?style=flat)](https://opensource.org/licenses/MIT)
31
+ [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/auth0/auth0-server-python)
27
32
 
28
33
  📚 [Documentation](#documentation) - 🚀 [Getting Started](#getting-started) - 💬 [Feedback](#feedback)
29
34
 
30
35
  ## Documentation
31
36
 
32
- - [Examples](https://github.com/auth0/auth0-server-python/blob/main/packages/auth0_server_python/EXAMPLES.md) - examples for your different use cases.
37
+ - [Examples](https://github.com/auth0/auth0-server-python/blob/main/examples) - examples for your different use cases.
33
38
  - [Docs Site](https://auth0.com/docs) - explore our docs site and learn more about Auth0.
34
39
 
35
40
  ## Getting Started
@@ -132,7 +137,7 @@ We appreciate feedback and contribution to this repo! Before you get started, pl
132
137
 
133
138
  - [Auth0's general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
134
139
  - [Auth0's code of conduct guidelines](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)
135
- - [This repo's contribution guide](./../../CONTRIBUTING.md)
140
+ - [This repo's contribution guide](./CONTRIBUTING.md)
136
141
 
137
142
  ### Raise an issue
138
143
 
@@ -155,5 +160,6 @@ Please do not report security vulnerabilities on the public GitHub issue tracker
155
160
  Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout <a href="https://auth0.com/why-auth0">Why Auth0?</a>
156
161
  </p>
157
162
  <p align="center">
158
- This project is licensed under the MIT license. See the <a href="https://github.com/auth0/auth0-server-python/blob/main/packages/auth0_server_python/LICENSE"> LICENSE</a> file for more info.
163
+ This project is licensed under the MIT license. See the <a href="https://github.com/auth0/auth0-server-python/blob/main/LICENSE"> LICENSE</a> file for more info.
159
164
  </p>
165
+
@@ -1,12 +1,15 @@
1
1
  The Auth0 Server Python SDK is a library for implementing user authentication in Python applications.
2
2
 
3
- ![PyPI](https://img.shields.io/pypi/v/auth0-server-python) ![Downloads](https://img.shields.io/pypi/dw/auth0-server-python) [![License](https://img.shields.io/:license-MIT-blue.svg?style=flat)](https://opensource.org/licenses/MIT)
3
+ ![PyPI](https://img.shields.io/pypi/v/auth0-server-python)
4
+ ![Downloads](https://img.shields.io/pypi/dw/auth0-server-python)
5
+ [![License](https://img.shields.io/:license-MIT-blue.svg?style=flat)](https://opensource.org/licenses/MIT)
6
+ [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/auth0/auth0-server-python)
4
7
 
5
8
  📚 [Documentation](#documentation) - 🚀 [Getting Started](#getting-started) - 💬 [Feedback](#feedback)
6
9
 
7
10
  ## Documentation
8
11
 
9
- - [Examples](https://github.com/auth0/auth0-server-python/blob/main/packages/auth0_server_python/EXAMPLES.md) - examples for your different use cases.
12
+ - [Examples](https://github.com/auth0/auth0-server-python/blob/main/examples) - examples for your different use cases.
10
13
  - [Docs Site](https://auth0.com/docs) - explore our docs site and learn more about Auth0.
11
14
 
12
15
  ## Getting Started
@@ -109,7 +112,7 @@ We appreciate feedback and contribution to this repo! Before you get started, pl
109
112
 
110
113
  - [Auth0's general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
111
114
  - [Auth0's code of conduct guidelines](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)
112
- - [This repo's contribution guide](./../../CONTRIBUTING.md)
115
+ - [This repo's contribution guide](./CONTRIBUTING.md)
113
116
 
114
117
  ### Raise an issue
115
118
 
@@ -132,5 +135,5 @@ Please do not report security vulnerabilities on the public GitHub issue tracker
132
135
  Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout <a href="https://auth0.com/why-auth0">Why Auth0?</a>
133
136
  </p>
134
137
  <p align="center">
135
- This project is licensed under the MIT license. See the <a href="https://github.com/auth0/auth0-server-python/blob/main/packages/auth0_server_python/LICENSE"> LICENSE</a> file for more info.
136
- </p>
138
+ This project is licensed under the MIT license. See the <a href="https://github.com/auth0/auth0-server-python/blob/main/LICENSE"> LICENSE</a> file for more info.
139
+ </p>
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "auth0-server-python"
3
- version = "1.0.0.b4"
3
+ version = "1.0.0.b6"
4
4
  description = "Auth0 server-side Python SDK"
5
5
  readme = "README.md"
6
6
  authors = ["Auth0 <support@okta.com>"]
@@ -25,9 +25,10 @@ pytest-cov = "^4.0"
25
25
  pytest-asyncio = "^0.20.3"
26
26
  pytest-mock = "^3.14.0"
27
27
  twine = "^6.1.0"
28
+ ruff = "^0.1.0"
28
29
 
29
30
  [tool.pytest.ini_options]
30
- addopts = "--cov=auth_server --cov-report=term-missing:skip-covered --cov-report=xml"
31
+ addopts = "--cov=auth0_server_python --cov-report=term-missing:skip-covered --cov-report=xml"
31
32
 
32
33
  [build-system]
33
34
  requires = ["poetry-core>=1.4.0"]
@@ -0,0 +1,3 @@
1
+ from .bearer_auth import BearerAuth
2
+
3
+ __all__ = ["BearerAuth"]
@@ -0,0 +1,10 @@
1
+ import httpx
2
+
3
+
4
+ class BearerAuth(httpx.Auth):
5
+ def __init__(self, token: str):
6
+ self.token = token
7
+
8
+ def auth_flow(self, request):
9
+ request.headers['Authorization'] = f"Bearer {self.token}"
10
+ yield request
@@ -0,0 +1,4 @@
1
+ from .my_account_client import MyAccountClient
2
+ from .server_client import ServerClient
3
+
4
+ __all__ = ["ServerClient", "MyAccountClient"]
@@ -0,0 +1,94 @@
1
+
2
+ import httpx
3
+ from auth0_server_python.auth_schemes.bearer_auth import BearerAuth
4
+ from auth0_server_python.auth_types import (
5
+ CompleteConnectAccountRequest,
6
+ CompleteConnectAccountResponse,
7
+ ConnectAccountRequest,
8
+ ConnectAccountResponse,
9
+ )
10
+ from auth0_server_python.error import (
11
+ ApiError,
12
+ MyAccountApiError,
13
+ )
14
+
15
+
16
+ class MyAccountClient:
17
+ def __init__(self, domain: str):
18
+ self._domain = domain
19
+
20
+ @property
21
+ def audience(self):
22
+ return f"https://{self._domain}/me/"
23
+
24
+ async def connect_account(
25
+ self,
26
+ access_token: str,
27
+ request: ConnectAccountRequest
28
+ ) -> ConnectAccountResponse:
29
+ try:
30
+ async with httpx.AsyncClient() as client:
31
+ response = await client.post(
32
+ url=f"{self.audience}v1/connected-accounts/connect",
33
+ json=request.model_dump(exclude_none=True),
34
+ auth=BearerAuth(access_token)
35
+ )
36
+
37
+ if response.status_code != 201:
38
+ error_data = response.json()
39
+ raise MyAccountApiError(
40
+ title=error_data.get("title", None),
41
+ type=error_data.get("type", None),
42
+ detail=error_data.get("detail", None),
43
+ status=error_data.get("status", None),
44
+ validation_errors=error_data.get("validation_errors", None)
45
+ )
46
+
47
+ data = response.json()
48
+
49
+ return ConnectAccountResponse.model_validate(data)
50
+
51
+ except Exception as e:
52
+ if isinstance(e, MyAccountApiError):
53
+ raise
54
+ raise ApiError(
55
+ "connect_account_error",
56
+ f"Connected Accounts connect request failed: {str(e) or 'Unknown error'}",
57
+ e
58
+ )
59
+
60
+ async def complete_connect_account(
61
+ self,
62
+ access_token: str,
63
+ request: CompleteConnectAccountRequest
64
+ ) -> CompleteConnectAccountResponse:
65
+ try:
66
+ async with httpx.AsyncClient() as client:
67
+ response = await client.post(
68
+ url=f"{self.audience}v1/connected-accounts/complete",
69
+ json=request.model_dump(exclude_none=True),
70
+ auth=BearerAuth(access_token)
71
+ )
72
+
73
+ if response.status_code != 201:
74
+ error_data = response.json()
75
+ raise MyAccountApiError(
76
+ title=error_data.get("title", None),
77
+ type=error_data.get("type", None),
78
+ detail=error_data.get("detail", None),
79
+ status=error_data.get("status", None),
80
+ validation_errors=error_data.get("validation_errors", None)
81
+ )
82
+
83
+ data = response.json()
84
+
85
+ return CompleteConnectAccountResponse.model_validate(data)
86
+
87
+ except Exception as e:
88
+ if isinstance(e, MyAccountApiError):
89
+ raise
90
+ raise ApiError(
91
+ "connect_account_error",
92
+ f"Connected Accounts complete request failed: {str(e) or 'Unknown error'}",
93
+ e
94
+ )