Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/carlagesa/django-auth0-
This sample demonstrates my ability to add authentication to a Django web app using Auth0 .
https://github.com/carlagesa/django-auth0-
auth0 auth0-jwt django-rest-framework
Last synced: about 1 month ago
JSON representation
This sample demonstrates my ability to add authentication to a Django web app using Auth0 .
- Host: GitHub
- URL: https://github.com/carlagesa/django-auth0-
- Owner: carlagesa
- Created: 2024-05-27T15:57:22.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-05-28T16:57:59.000Z (6 months ago)
- Last Synced: 2024-10-14T01:41:44.181Z (about 1 month ago)
- Topics: auth0, auth0-jwt, django-rest-framework
- Language: Python
- Homepage:
- Size: 164 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Django Auth0 Integration
## IntroductionAuth0 is a powerful identity management platform that allows developers to add authentication and authorization services to their applications. This Django project showcases how to implement Auth0 authentication in a Django application, providing users with secure and seamless access.
This project demonstrates how to integrate Auth0 authentication into a Django application.
## API Reference
#### The routes shown below are available for the following requests:
#### Available for non-authenticated requests```http
GET /api/public
```#### Available for authenticated requests containing an access token with no additional scopes
```http
GET /api/private
```
#### Available for authenticated requests containing an access token with the read:messages scope granted
```http
GET /api/private-scoped
```# Running the example
In order to run the example, you need to have `python` and `pip` installed.
You also need to set your Auth0 Domain and the API's audience as environment variables with the following names
respectively: `AUTH0_DOMAIN` and `API_IDENTIFIER`, which is the audience of your API. You can find an example in the
`env.example` file.For that, if you just create a file named `.env` in the directory and set the values like the following,
the app will just work:```bash
# .env file
AUTH0_DOMAIN=example.auth0.com
API_IDENTIFIER=YOUR_API_AUDIENCE```
Once you've set those 2 environment variables:
1. Install the needed dependencies with `pip install -r requirements.txt`
2. Migrate the database with `python manage.py migrate`
3. Start the server with `python manage.py runserver 3010`
4. Try calling [http://localhost:3010/api/public](http://localhost:3010/api/public)# Testing the API
You can then try to do a GET to [http://localhost:3010/api/private](http://localhost:3010/api/private) which will
throw an error if you don't send an access token signed with RS256 with the appropriate issuer and audience in the
Authorization header.You can also try to do a GET to
[http://localhost:3010/api/private-scoped/](http://localhost:3010/api/private-scoped) which will throw an error if
you don't send an access token with the scope `read:messages` signed with RS256 with the appropriate issuer and audience
in the Authorization header.
## Screenshots
This is what will show upon successfull connection
This is what will show upon a failed connection
## Links
For more info check https://auth0.com/docs/quickstart/backend/django## Authors
- [@carlagesa](https://www.github.com/carlagesa)