Authenticated users using Auth0.
Project description
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:
```python
AUTHENTICATION_BACKENDS = (
...
'auth0_auth.backends.Auth0Backend',
)
```
Edit your `urls.py` to include:
```python
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.
```python
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.
```python
LOGGING = {
...,
'loggers': {
...,
'auth0_auth': {
'handlers': ['console'],
'level': 'DEBUG',
}
}
}
```
=================
*Django Auth0 Auth* allows you to authenticate through Auth0.
Installation
------------
Run `pip install django-auth0-auth`
Add the `Auth0Backend` to your `AUTHENTICATION_BACKENDS` setting:
```python
AUTHENTICATION_BACKENDS = (
...
'auth0_auth.backends.Auth0Backend',
)
```
Edit your `urls.py` to include:
```python
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.
```python
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.
```python
LOGGING = {
...,
'loggers': {
...,
'auth0_auth': {
'handlers': ['console'],
'level': 'DEBUG',
}
}
}
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-auth0-auth-3.0.1.tar.gz.
File metadata
- Download URL: django-auth0-auth-3.0.1.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4438d567ad851eccdbcf2f90134f91e58b7b7dc0f7f4ea6cd07b22ffa2e949ec
|
|
| MD5 |
d24414fd2393a3960f461cd96f598e02
|
|
| BLAKE2b-256 |
bd4e8820ed24990c510c7194be5119dd1a34d00dc796ed9cb359ae70934b7666
|
File details
Details for the file django_auth0_auth-3.0.1-py2-none-any.whl.
File metadata
- Download URL: django_auth0_auth-3.0.1-py2-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18ddb8604f93e2b77d2bc7523830c0c681376a620c814acd152e632e1b6ec9f4
|
|
| MD5 |
4d04117307a566e20b0735556a61ccdf
|
|
| BLAKE2b-256 |
6930d219df9108d239e9d7eb808ed4fee3c09821a9ca73cee549e0da2aaeaa1d
|