auth0-server-python 1.0.0b1__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.
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Auth0, Inc. <support@auth0.com> (http://auth0.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,160 @@
1
+ Metadata-Version: 2.3
2
+ Name: auth0-server-python
3
+ Version: 1.0.0b1
4
+ Summary: Auth0 server-side Python SDK
5
+ License: MIT
6
+ Author: Snehil Kishore
7
+ Author-email: snehil.kishore@okta.com
8
+ Requires-Python: >=3.9
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Requires-Dist: authlib (>=1.2,<2.0)
17
+ Requires-Dist: cryptography (>=43.0.1)
18
+ Requires-Dist: fastapi (>=0.115.11,<0.116.0)
19
+ Requires-Dist: httpx (>=0.28.1,<0.29.0)
20
+ Requires-Dist: jwcrypto (>=1.5.6,<2.0.0)
21
+ Requires-Dist: pydantic (>=2.10.6,<3.0.0)
22
+ Requires-Dist: pyjwt (>=2.8.0)
23
+ Description-Content-Type: text/markdown
24
+
25
+ The Auth0 Server Python SDK is a library for implementing user authentication in Python applications.
26
+
27
+ ![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) [![Codecov](https://img.shields.io/codecov/c/github/auth0/auth0-server-python)](https://codecov.io/gh/auth0/auth0-server-python) [![CI](https://github.com/auth0/auth0-server-python/actions/workflows/ci.yml/badge.svg)](https://github.com/auth0/auth0-server-python/actions)
28
+
29
+ ๐Ÿ“š [Documentation](#documentation) - ๐Ÿš€ [Getting Started](#getting-started) - ๐Ÿ’ฌ [Feedback](#feedback)
30
+
31
+ ## Documentation
32
+
33
+ - [Examples](https://github.com/auth0/auth0-server-python/blob/main/packages/auth0_server_python/EXAMPLES.md) - examples for your different use cases.
34
+ - [Docs Site](https://auth0.com/docs) - explore our docs site and learn more about Auth0.
35
+
36
+ ## Getting Started
37
+
38
+ ### 1. Install the SDK
39
+
40
+ ```shell
41
+ pip install auth0-server-python
42
+ ```
43
+
44
+ If youโ€™re using Poetry:
45
+
46
+ ```shell
47
+ poetry install auth0-server-python
48
+ ```
49
+
50
+ ### 2. Create the Auth0 SDK client
51
+
52
+ Create an instance of the Auth0 client. This instance will be imported and used in anywhere we need access to the authentication methods.
53
+
54
+
55
+ ```python
56
+ from auth0_server_python import ServerClient
57
+
58
+ auth0 = ServerClient(
59
+ domain='<AUTH0_DOMAIN>',
60
+ client_id='<AUTH0_CLIENT_ID>',
61
+ client_secret='<AUTH0_CLIENT_SECRET>',
62
+ secret='<AUTH0_SECRET>',
63
+ authorization_params= {
64
+ redirect_uri: '<AUTH0_REDIRECT_URI>',
65
+ }
66
+ )
67
+ ```
68
+
69
+ The `AUTH0_DOMAIN`, `AUTH0_CLIENT_ID`, and `AUTH0_CLIENT_SECRET` can be obtained from the [Auth0 Dashboard](https://manage.auth0.com) once you've created an application. **This application must be a `Regular Web Application`**.
70
+
71
+ The `AUTH0_REDIRECT_URI` tells Auth0 what URL to use while redirecting the user back after successful authentication, e.g. `http://localhost:3000/auth/callback`. Note: your application needs to handle this endpoint and call the SDK's `complete_interactive_login(url: string)` to finish the authentication process. See below for more information.
72
+
73
+ The `AUTH0_SECRET` is the key used to encrypt the session and transaction cookies. You can generate a secret using `openssl`:
74
+
75
+ ```shell
76
+ openssl rand -hex 64
77
+ ```
78
+
79
+ ### 3. Add login to your Application (interactive)
80
+
81
+ Before using redirect-based login, ensure the `redirect_uri` is configured when initializing the SDK:
82
+
83
+ ```python
84
+ auth0 = ServerClient(
85
+ # ...
86
+ redirect_uri='<AUTH0_REDIRECT_URI>',
87
+ # ...
88
+ )
89
+ ```
90
+
91
+ > [!IMPORTANT]
92
+ > You will need to register the `AUTH0_REDIRECT_URI` in your Auth0 Application as an **Allowed Callback URLs** via the [Auth0 Dashboard](https://manage.auth0.com).
93
+
94
+ In order to add login to any application, call `start_interactive_login()`, and redirect the user to the returned URL.
95
+
96
+ The implementation will vary based on the framework being used, but here is an example of what this would look like in FastAPI:
97
+
98
+ ```python
99
+ from fastapi import FastAPI, Request, Response
100
+ from starlette.responses import RedirectResponse
101
+
102
+ app = FastAPI()
103
+
104
+
105
+ @app.get("/auth/login")
106
+ async def login(request: Request):
107
+ authorization_url = await auth0.start_interactive_login()
108
+ return RedirectResponse(url=authorization_url)
109
+ ```
110
+
111
+ Once the user has successfully authenticated, Auth0 will redirect the user back to the provided `redirect_uri` which needs to be handled in the application.
112
+
113
+ This implementation will also vary based on the framework used, but what needs to happen is:
114
+
115
+ - register an endpoint that will handle the configured `redirect_uri`.
116
+ - call the SDK's `complete_interactive_login(url)`, passing it the full URL, including query parameters.
117
+
118
+ Here is an example of what this would look like in FastAPI, with `redirect_uri` configured as `http://localhost:3000/auth/callback`:
119
+
120
+ ```python
121
+ @app.get("/auth/callback")
122
+ async def callback(request: Request):
123
+ result = await auth0.complete_interactive_login(str(request.url))
124
+ # Store session or set cookies as needed
125
+ return RedirectResponse(url="/")
126
+ ```
127
+
128
+ ## Feedback
129
+
130
+ ### Contributing
131
+
132
+ We appreciate feedback and contribution to this repo! Before you get started, please read the following:
133
+
134
+ - [Auth0's general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
135
+ - [Auth0's code of conduct guidelines](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)
136
+ - [This repo's contribution guide](./CONTRIBUTING.md)
137
+
138
+ ### Raise an issue
139
+
140
+ To provide feedback or report a bug, please [raise an issue on our issue tracker](https://github.com/auth0/auth0-server-python/issues).
141
+
142
+ ## Vulnerability Reporting
143
+
144
+ Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/responsible-disclosure-policy) details the procedure for disclosing security issues.
145
+
146
+ ## What is Auth0?
147
+
148
+ <p align="center">
149
+ <picture>
150
+ <source media="(prefers-color-scheme: dark)" srcset="https://cdn.auth0.com/website/sdks/logos/auth0_dark_mode.png" width="150">
151
+ <source media="(prefers-color-scheme: light)" srcset="https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png" width="150">
152
+ <img alt="Auth0 Logo" src="https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png" width="150">
153
+ </picture>
154
+ </p>
155
+ <p align="center">
156
+ 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>
157
+ </p>
158
+ <p align="center">
159
+ 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.
160
+ </p>
@@ -0,0 +1,136 @@
1
+ The Auth0 Server Python SDK is a library for implementing user authentication in Python applications.
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) [![Codecov](https://img.shields.io/codecov/c/github/auth0/auth0-server-python)](https://codecov.io/gh/auth0/auth0-server-python) [![CI](https://github.com/auth0/auth0-server-python/actions/workflows/ci.yml/badge.svg)](https://github.com/auth0/auth0-server-python/actions)
4
+
5
+ ๐Ÿ“š [Documentation](#documentation) - ๐Ÿš€ [Getting Started](#getting-started) - ๐Ÿ’ฌ [Feedback](#feedback)
6
+
7
+ ## Documentation
8
+
9
+ - [Examples](https://github.com/auth0/auth0-server-python/blob/main/packages/auth0_server_python/EXAMPLES.md) - examples for your different use cases.
10
+ - [Docs Site](https://auth0.com/docs) - explore our docs site and learn more about Auth0.
11
+
12
+ ## Getting Started
13
+
14
+ ### 1. Install the SDK
15
+
16
+ ```shell
17
+ pip install auth0-server-python
18
+ ```
19
+
20
+ If youโ€™re using Poetry:
21
+
22
+ ```shell
23
+ poetry install auth0-server-python
24
+ ```
25
+
26
+ ### 2. Create the Auth0 SDK client
27
+
28
+ Create an instance of the Auth0 client. This instance will be imported and used in anywhere we need access to the authentication methods.
29
+
30
+
31
+ ```python
32
+ from auth0_server_python import ServerClient
33
+
34
+ auth0 = ServerClient(
35
+ domain='<AUTH0_DOMAIN>',
36
+ client_id='<AUTH0_CLIENT_ID>',
37
+ client_secret='<AUTH0_CLIENT_SECRET>',
38
+ secret='<AUTH0_SECRET>',
39
+ authorization_params= {
40
+ redirect_uri: '<AUTH0_REDIRECT_URI>',
41
+ }
42
+ )
43
+ ```
44
+
45
+ The `AUTH0_DOMAIN`, `AUTH0_CLIENT_ID`, and `AUTH0_CLIENT_SECRET` can be obtained from the [Auth0 Dashboard](https://manage.auth0.com) once you've created an application. **This application must be a `Regular Web Application`**.
46
+
47
+ The `AUTH0_REDIRECT_URI` tells Auth0 what URL to use while redirecting the user back after successful authentication, e.g. `http://localhost:3000/auth/callback`. Note: your application needs to handle this endpoint and call the SDK's `complete_interactive_login(url: string)` to finish the authentication process. See below for more information.
48
+
49
+ The `AUTH0_SECRET` is the key used to encrypt the session and transaction cookies. You can generate a secret using `openssl`:
50
+
51
+ ```shell
52
+ openssl rand -hex 64
53
+ ```
54
+
55
+ ### 3. Add login to your Application (interactive)
56
+
57
+ Before using redirect-based login, ensure the `redirect_uri` is configured when initializing the SDK:
58
+
59
+ ```python
60
+ auth0 = ServerClient(
61
+ # ...
62
+ redirect_uri='<AUTH0_REDIRECT_URI>',
63
+ # ...
64
+ )
65
+ ```
66
+
67
+ > [!IMPORTANT]
68
+ > You will need to register the `AUTH0_REDIRECT_URI` in your Auth0 Application as an **Allowed Callback URLs** via the [Auth0 Dashboard](https://manage.auth0.com).
69
+
70
+ In order to add login to any application, call `start_interactive_login()`, and redirect the user to the returned URL.
71
+
72
+ The implementation will vary based on the framework being used, but here is an example of what this would look like in FastAPI:
73
+
74
+ ```python
75
+ from fastapi import FastAPI, Request, Response
76
+ from starlette.responses import RedirectResponse
77
+
78
+ app = FastAPI()
79
+
80
+
81
+ @app.get("/auth/login")
82
+ async def login(request: Request):
83
+ authorization_url = await auth0.start_interactive_login()
84
+ return RedirectResponse(url=authorization_url)
85
+ ```
86
+
87
+ Once the user has successfully authenticated, Auth0 will redirect the user back to the provided `redirect_uri` which needs to be handled in the application.
88
+
89
+ This implementation will also vary based on the framework used, but what needs to happen is:
90
+
91
+ - register an endpoint that will handle the configured `redirect_uri`.
92
+ - call the SDK's `complete_interactive_login(url)`, passing it the full URL, including query parameters.
93
+
94
+ Here is an example of what this would look like in FastAPI, with `redirect_uri` configured as `http://localhost:3000/auth/callback`:
95
+
96
+ ```python
97
+ @app.get("/auth/callback")
98
+ async def callback(request: Request):
99
+ result = await auth0.complete_interactive_login(str(request.url))
100
+ # Store session or set cookies as needed
101
+ return RedirectResponse(url="/")
102
+ ```
103
+
104
+ ## Feedback
105
+
106
+ ### Contributing
107
+
108
+ We appreciate feedback and contribution to this repo! Before you get started, please read the following:
109
+
110
+ - [Auth0's general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
111
+ - [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)
113
+
114
+ ### Raise an issue
115
+
116
+ To provide feedback or report a bug, please [raise an issue on our issue tracker](https://github.com/auth0/auth0-server-python/issues).
117
+
118
+ ## Vulnerability Reporting
119
+
120
+ Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/responsible-disclosure-policy) details the procedure for disclosing security issues.
121
+
122
+ ## What is Auth0?
123
+
124
+ <p align="center">
125
+ <picture>
126
+ <source media="(prefers-color-scheme: dark)" srcset="https://cdn.auth0.com/website/sdks/logos/auth0_dark_mode.png" width="150">
127
+ <source media="(prefers-color-scheme: light)" srcset="https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png" width="150">
128
+ <img alt="Auth0 Logo" src="https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png" width="150">
129
+ </picture>
130
+ </p>
131
+ <p align="center">
132
+ 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
+ </p>
134
+ <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>
@@ -0,0 +1,39 @@
1
+ [tool.poetry]
2
+ name = "auth0-server-python"
3
+ version = "1.0.0.b1"
4
+ description = "Auth0 server-side Python SDK"
5
+ readme = "README.md"
6
+ authors = ["Snehil Kishore <snehil.kishore@okta.com>"]
7
+ license = "MIT"
8
+
9
+ packages = [
10
+ { include = "auth_server", from = "src" },
11
+ { include = "auth_types", from = "src" },
12
+ { include = "encryption", from = "src" },
13
+ { include = "error", from = "src" },
14
+ { include = "store", from = "src" },
15
+ { include = "utils", from = "src" }
16
+ ]
17
+
18
+ [tool.poetry.dependencies]
19
+ python = ">=3.9"
20
+ cryptography = ">=43.0.1" # pyjwt has a weak dependency on cryptography
21
+ pyjwt = ">=2.8.0"
22
+ authlib = "^1.2"
23
+ httpx = "^0.28.1"
24
+ pydantic = "^2.10.6"
25
+ fastapi = "^0.115.11"
26
+ jwcrypto = "^1.5.6"
27
+
28
+ [tool.poetry.group.dev.dependencies]
29
+ pytest = "^7.2"
30
+ pytest-cov = "^4.0"
31
+ pytest-asyncio = "^0.20.3"
32
+ pytest-mock = "^3.14.0"
33
+
34
+ [tool.pytest.ini_options]
35
+ addopts = "--cov=auth_server --cov-report=term-missing:skip-covered --cov-report=xml"
36
+
37
+ [build-system]
38
+ requires = ["poetry-core>=1.4.0"]
39
+ build-backend = "poetry.core.masonry.api"
@@ -0,0 +1,4 @@
1
+ from .server_client import ServerClient
2
+
3
+
4
+ __all__ = ["ServerClient"]