Skip to content

Commit d623091

Browse files
Merge pull request #5 from auth0/main-branch-sync
Publishing the SDKs
2 parents 565925d + 0ff8504 commit d623091

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+12532
-5
lines changed

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
### Python ###
2+
# Byte-compiled / optimized / DLL files
3+
__pycache__/
4+
*.py[cod]
5+
*$py.class
6+
7+
#Environments
8+
.env
9+
.venv
10+
env/
11+
12+
#Session Cache
13+
.sessions_cache
14+
.DS_Store
15+
16+
#Build files
17+
dist
18+
docs
19+
20+
#testfile
21+
server.py
22+
setup.py
23+
test.py
24+
test-script.py
25+
.coverage
26+
coverage.xml
27+

CONTRIBUTING.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Contribution
2+
3+
Please read [Auth0's contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md).
4+
5+
## Environment setup
6+
7+
- Make sure you have node and npm installed
8+
- Run `poetry install` to install dependencies
9+
- Follow the local development steps below to get started
10+
11+
## Local development
12+
13+
- `poetry install`: install dependencies
14+
- `poetry run pytest`: run unit tests
15+
- `poetry build`: compile the package
16+
17+
## Testing
18+
19+
### Adding tests
20+
21+
Every change should be accompanied by a test.
22+
23+
### Running tests
24+
25+
Run unit tests before opening a PR:
26+
27+
```bash
28+
poetry run pytest
29+
```
30+
31+
Also include any information about essential manual tests.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017 Auth0, Inc. <[email protected]> (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.

README.md

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,56 @@
1-
Welcome to your new repo,auth0-server-python!
1+
Auth0 Auth Python Mono Repo, containing SDKs for implementing user authentication in Python applications.
22

3-
This is a default readme file created to provide some helpful links and first steps.
4-
A lot of your questions might already exist in our [wiki page](http://bit.ly/EngFAQ), so please check there first.
3+
![Release](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)
54

6-
Please reach out to us over on [#eng-release](https://okta.slack.com/archives/C7L27G2Q5) or
7-
[#eng-productivity](https://okta.slack.com/archives/C7LQ4U8T0) for any additional assistance you might require.
5+
📚 [Packages](#packages) - 💬 [Feedback](#feedback)
6+
7+
8+
## Packages
9+
- [auth0-api-python](./packages/auth0-api-python/README.md)
10+
**Authentication SDK for securing APIs on Python** (JWT verification, claims checks, etc.)
11+
12+
- [auth0-server-python](./packages/auth0-server-python/README.md)
13+
**Authentication SDK for server-side Python apps**, built on Authlib. Handles OAuth flows, session logic.
14+
15+
- [auth0-fastapi](./packages/auth0-fastapi/README.md)
16+
**Authentication SDK for FastAPI**. Provides routes, session/cookie handling, and user linking.
17+
18+
- [auth0-fastapi-api](./packages/auth0-fastapi-api/README.md)
19+
**Additional tooling** for combining `auth0-fastapi` with custom API flows.
20+
21+
>[!IMPORTANT]
22+
> You might see `auth0-server-python` in the above packages list but don't get confused. In future, this repository will point to one SDK i.e.`auth0-server-python` and rest all SDKS will have their own respective repositories.
23+
24+
## Feedback
25+
26+
### Contributing
27+
28+
We appreciate feedback and contribution to this repo! Before you get started, please read the following:
29+
30+
- [Auth0's general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
31+
- [Auth0's code of conduct guidelines](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)
32+
- [This repo's contribution guide](./CONTRIBUTING.md)
33+
34+
### Raise an issue
35+
36+
To provide feedback or report a bug, please [raise an issue on our issue tracker](https://github.com/auth0/auth0-server-python/issues).
37+
38+
## Vulnerability Reporting
39+
40+
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.
41+
42+
## What is Auth0?
43+
44+
<p align="center">
45+
<picture>
46+
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.auth0.com/website/sdks/logos/auth0_dark_mode.png" width="150">
47+
<source media="(prefers-color-scheme: light)" srcset="https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png" width="150">
48+
<img alt="Auth0 Logo" src="https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png" width="150">
49+
</picture>
50+
</p>
51+
<p align="center">
52+
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>
53+
</p>
54+
<p align="center">
55+
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.
56+
</p>

packages/__init__.py

Whitespace-only changes.

packages/auth0_api_python/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017 Auth0, Inc. <[email protected]> (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.
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
The `auth0-api-python` library allows you to secure APIs running on Python, particularly for verifying Auth0-issued access tokens.
2+
3+
It’s intended as a foundation for building more framework-specific integrations (e.g., with FastAPI, Django, etc.), but you can also use it directly in any Python server-side environment.
4+
5+
![Release](https://img.shields.io/pypi/v/auth0-api-python) ![Downloads](https://img.shields.io/pypi/dw/auth0-api-python) [![License](https://img.shields.io/:license-MIT-blue.svg?style=flat)](https://opensource.org/licenses/MIT)
6+
7+
📚 [Documentation](#documentation) - 🚀 [Getting Started](#getting-started) - 💬 [Feedback](#feedback)
8+
9+
## Documentation
10+
11+
- [Docs Site](https://auth0.com/docs) - explore our docs site and learn more about Auth0.
12+
13+
## Getting Started
14+
15+
### 1. Install the SDK
16+
17+
_This library requires Python 3.9+._
18+
19+
```shell
20+
pip install auth0-api-python
21+
```
22+
23+
If you’re using Poetry:
24+
25+
```shell
26+
poetry install auth0-api-python
27+
```
28+
29+
### 2. Create the Auth0 SDK client
30+
31+
Create an instance of the `ApiClient`. This instance will be imported and used anywhere we need access to the methods.
32+
33+
```python
34+
from auth0_api_python import ApiClient, ApiClientOptions
35+
36+
37+
api_client = ApiClient(ApiClientOptions(
38+
domain="<AUTH0_DOMAIN>",
39+
audience="<AUTH0_AUDIENCE>"
40+
))
41+
```
42+
43+
- The `AUTH0_DOMAIN` can be obtained from the [Auth0 Dashboard](https://manage.auth0.com) once you've created an application.
44+
- The `AUTH0_AUDIENCE` is the identifier of the API. You can find this in the [APIs section of the Auth0 Dashboard](https://manage.auth0.com/#/apis/).
45+
46+
### 3. Verify the Access Token
47+
48+
Use the `verify_access_token` method to validate access tokens. The method automatically checks critical claims like `iss`, `aud`, `exp`, `nbf`.
49+
50+
```python
51+
import asyncio
52+
53+
from auth0_api_python import ApiClient, ApiClientOptions
54+
55+
async def main():
56+
api_client = ApiClient(ApiClientOptions(
57+
domain="<AUTH0_DOMAIN>",
58+
audience="<AUTH0_AUDIENCE>"
59+
))
60+
access_token = "..."
61+
62+
decoded_and_verified_token = await api_client.verify_access_token(access_token=access_token)
63+
print(decoded_and_verified_token)
64+
65+
asyncio.run(main())
66+
```
67+
68+
In this example, the returned dictionary contains the decoded claims (like `sub`, `scope`, etc.) from the verified token.
69+
70+
#### Requiring Additional Claims
71+
72+
If your application demands extra claims, specify them with `required_claims`:
73+
74+
```python
75+
decoded_and_verified_token = await api_client.verify_access_token(
76+
access_token=access_token,
77+
required_claims=["my_custom_claim"]
78+
)
79+
```
80+
81+
If the token lacks `my_custom_claim` or fails any standard check (issuer mismatch, expired token, invalid signature), the method raises a `VerifyAccessTokenError`.
82+
83+
## Feedback
84+
85+
### Contributing
86+
87+
We appreciate feedback and contribution to this repo! Before you get started, please read the following:
88+
89+
- [Auth0's general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
90+
- [Auth0's code of conduct guidelines](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)
91+
- [This repo's contribution guide](./../../CONTRIBUTING.md)
92+
93+
### Raise an issue
94+
95+
To provide feedback or report a bug, please [raise an issue on our issue tracker](https://github.com/auth0/auth0-server-python/issues).
96+
97+
## Vulnerability Reporting
98+
99+
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.
100+
101+
## What is Auth0?
102+
103+
<p align="center">
104+
<picture>
105+
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.auth0.com/website/sdks/logos/auth0_dark_mode.png" width="150">
106+
<source media="(prefers-color-scheme: light)" srcset="https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png" width="150">
107+
<img alt="Auth0 Logo" src="https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png" width="150">
108+
</picture>
109+
</p>
110+
<p align="center">
111+
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>
112+
</p>
113+
<p align="center">
114+
This project is licensed under the MIT license. See the <a href="https://github.com/auth0/auth0-server-python/blob/main/packages/auth0_api_python/LICENSE"> LICENSE</a> file for more info.
115+
</p>

0 commit comments

Comments
 (0)