Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/descope/django-descope
Descope plugin for Django framework
https://github.com/descope/django-descope
app authentication descope django plugin python sdk
Last synced: 7 days ago
JSON representation
Descope plugin for Django framework
- Host: GitHub
- URL: https://github.com/descope/django-descope
- Owner: descope
- License: mit
- Created: 2022-08-11T12:16:09.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-05T19:15:07.000Z (9 days ago)
- Last Synced: 2024-11-05T20:26:24.971Z (9 days ago)
- Topics: app, authentication, descope, django, plugin, python, sdk
- Language: Python
- Homepage: https://docs.descope.com
- Size: 556 KB
- Stars: 28
- Watchers: 11
- Forks: 5
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Descope Django App
Descope is a user management and authentication platform.
This plugin integrates Descope with your Django app.## Quick start
1. Sign up for Descope and set admin roles
- Get your project id
- Create two roles in Descope, that will be mapped to Django permissions
- is_staff
- is_superuserMap these roles to any user you would like to make a staff or superuser in your Django app.
_The names of these roles can be customized in the settings below._2. Install "django-descope" and add to your INSTALLED_APPS setting like this:
```bash
poetry add django-descope
OR
pip install django-descope
``````
INSTALLED_APPS = [
...
'django_descope',
]
```3. Add Descope Middleware **after** the AuthenticationMiddleware and SessionMiddleware
```
MIDDLEWARE = [
...
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
...
'django_descope.middleware.DescopeMiddleware',
]
```4. Include descope URLconf in your project urls.py like this:
```
path('auth/', include('django_descope.urls')),
```5. In your site templates, insert the `descope_flow` tag where you want to place your flow
```html
{% load descope %}{% if user.is_authenticated %}
Welcome {{ user.email }} you are logged in!
{% else %} {% descope_flow "sign-up-or-in" "/" %}{% endif %}
```6. Start the development server and visit the newly created view
## Testing
See [test_admin.py](example_app/test_admin.py) for a rudimentary example of
how to utilize [Descope Test Users](https://docs.descope.com/manage/testusers/)
when testing your application with authenticated users.
You can use the helper [`django_descope.authentication.add_tokens_to_request`](django_descope/authentication.py) to add the tokens to the django session> [!IMPORTANT]
> Remember you must create the relevant roles in [Descope Console](https://app.descope.com)
> so you can utilize them in your testing.## Settings
The following settings are available to configure in your project `settings.py`
#### Required
```
DESCOPE_PROJECT_ID
```#### Optional
```
DESCOPE_MANAGEMENT_KEY
DESCOPE_IS_STAFF_ROLE
DESCOPE_IS_SUPERUSER_ROLE
```