Skip to main content

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_superuser

Map 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.

  1. Install "django-descope" and add to your INSTALLED_APPS setting like this:
uv add django-descope
OR
pip install django-descope
   INSTALLED_APPS = [
   ...
   'django_descope',
   ]
  1. Add Descope Middleware after the AuthenticationMiddleware and SessionMiddleware
   MIDDLEWARE = [
   ...
   'django.contrib.sessions.middleware.SessionMiddleware',
   'django.contrib.auth.middleware.AuthenticationMiddleware',
   ...
   'django_descope.middleware.DescopeMiddleware',
   ]
  1. Include descope URLconf in your project urls.py like this:
   path('auth/', include('django_descope.urls')),
  1. In your site templates, insert the descope_flow tag where you want to place your flow
{% load descope %}
<!-- load the descope registry -->

{% if user.is_authenticated %}
<h1>Welcome {{ user.email }} you are logged in!</h1>
<p><a href="{% url 'logout' %}">Log Out</a></p>
{% else %} {% descope_flow "sign-up-or-in" "/" %}
<!-- provide the descope flow id, and where to redirect after a successful login-->
{% endif %}
  1. Start the development server and visit the newly created view

Testing

See test_admin.py for a rudimentary example of how to utilize Descope Test Users when testing your application with authenticated users. You can use the helper django_descope.authentication.add_tokens_to_request to add the tokens to the django session

Local development

uv sync
uv run ruff check .
uv run python manage.py test

Set DESCOPE_PROJECT_ID and DESCOPE_MANAGEMENT_KEY before running tests that create Descope test users.

[!IMPORTANT] Remember you must create the relevant roles in Descope Console 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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_descope-3.0.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_descope-3.0.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file django_descope-3.0.0.tar.gz.

File metadata

  • Download URL: django_descope-3.0.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for django_descope-3.0.0.tar.gz
Algorithm Hash digest
SHA256 cfd27d917ff133eceb69bce9cb9bd15213d5df19277116a93fe6ea9c14e9444b
MD5 4dffb96ea7ccd563fad6f73b7b123f3d
BLAKE2b-256 7bf525cde1519a645de3aeecc96cfbdf3779085cb60550d7bfff0a9317c74337

See more details on using hashes here.

File details

Details for the file django_descope-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: django_descope-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for django_descope-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 330a08d9ef2f83c66f7f7b9435b8158ea05698e982941dc14aa9275174e7358a
MD5 4c200f0cdb1a64ca89593aebe23f334e
BLAKE2b-256 314ca64e6c1a73e8c5079c3b2b57d417ce081ba7178c8a1e51df88b977766c6b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

3.0.0 This release

2 files

2.1.0

2 files

2.0.2

2 files

2.0.1

2 files

2.0.0

2 files

1.4.0

2 files

1.3.2

2 files

1.3.1

2 files

1.3.0

2 files

1.2.0

2 files

1.1.0

2 files

1.0.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page