Skip to main content

Django Auth0 Auth

Django Auth0 Auth allows you to authenticate through Auth0.

Installation

Run pip install django-auth0-auth

Add the Auth0Backend to your AUTHENTICATION_BACKENDS setting:

AUTHENTICATION_BACKENDS = (
    ...
    'auth0_auth.backends.Auth0Backend',
)

Edit your urls.py to include:

urlpatterns = [
    url(r'^auth0/', include('auth0_auth.urls')),
    ...
]

Settings

###AUTH0_DOMAIN

Auth0 domain.

###AUTH0_CLIENT_ID

Auth0 client id.

###AUTH0_CLIENT_SECRET

Auth0 client secret.

###AUTH0_SECRET_BASE64_ENCODED

default: False Flag if Auth0 client secret is base64 encoded.

###AUTH0_SCOPE

default: 'openid email' OAuth scope parameter.

###AUTH0_RESPONSE_TYPE

default: 'token' OAuth response type parameter.

###AUTH0_USER_CREATION

default: True Allow creation of new users after successful authentication.

Lock Signin

To log in using the JavaScript based Lock dialog, add the following to your project.

Add the auth0 context processor to the TEMPLATES options.

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'OPTIONS': {
            'context_processors': [
                ...
                'auth0_auth.context_processors.auth0',
            ],
        },
    },
]

Add the following JavaScript snippet to your base.html below your sites other JavaScript.

<script src="https://cdn.auth0.com/js/lock-9.min.js"></script>
<script type="text/javascript">
    var lock = new Auth0Lock('{{ AUTH0_CLIENT_ID }}', '{{ AUTH0_DOMAIN }}');
    function signin() {
        lock.show({
            callbackURL: '{{ AUTH0_CALLBACK_URL }}',
            responseType: 'token',
            authParams: {
                'scope': '{{ AUTH0_SCOPE }}',
                'response_mode': 'form_post',
                'state': '{{ AUTH0_STATE }}'
            }
        });
    }
</script>

Add a login button to your base.html.

<button onclick="window.signin();">Login</button>

Logging

To enable logging add auth0_auth to LOGGING['loggers'] options.

LOGGING = {
    ...,
    'loggers': {
        ...,
        'auth0_auth': {
            'handlers': ['console'],
            'level': 'DEBUG',
        }
    }
}

Metadata

Release files for django-auth0-auth 3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-auth0-auth 3.3
File Size Uploaded Provenance Actions
django-auth0-auth-3.3.tar.gz 7.0 kB Without provenance Details for django-auth0-auth-3.3.tar.gz

Release files / django-auth0-auth-3.3.tar.gz

Download URL django-auth0-auth-3.3.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f05ab0fc0703e87522c5610335ec85fc18de057ef5069ceb7e3542817b4552cd
BLAKE2b-256 checksum
How to use checksums
7d81153efe0acb7acc40f7ee86977ec3916da22f81ad40e9ad754e5833d40655
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

Security for django-auth0-auth 3.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page