Django SSL Client Authentication
Project description
SSL authentication backend and middleware for Django for authenticating users with SSL client certificates
License
MIT license, see LICENSE.txt for full text.
Setup
SSL
Set up nginx and create SSL certificates for your server and set up the paths to server private key, server certificate and CA certificate used to sign the client certificates. Example configuration file is in samples/nginx.conf
If you are on OS X, I suggest OS X KeyChain access for doing this for testing, as it will automatically make your client certificates available in all both Google chrome & Safari. Instructions can be found e.g. http://www.dummies.com/how-to/content/how-to-become-a-certificate-authority-using-lion-s.html
On other platforms, there are many tutorials on how to do this with OpenSSL e.g. http://pages.cs.wisc.edu/~zmiller/ca-howto/
Restart your ngninx (sudo nginx -s restart), make sure your green unicorn is running and check that your https:// url loads your application and the server certificate is valid.
This module
run setup.py (sudo python setup.py install) or install the latest release using pip install django_ssl_auth
edit your settings.py
add "django_ssl_auth.SSLClientAuthMiddleware" to your MIDDLEWARE_CLASSES
add "django_ssl_auth.SSLClientAuthBackend" to your AUTHENTICATION_BACKENDS
Configuration
There are two things you need to do in settings.py
Define a function that can return a dictionary with fields that are required by your user model, e.g. USER_DATA_FN = 'django_ssl_auth.fineid.user_dict_from_dn is a sample implementation that takes the required fields from the DN of a Finnish government issued ID smart card for the contrib.auth.models.User.
To automatically create User``s for all valid certificate holders, set ``AUTOCREATE_VALID_SSL_USERS = True. Auto-created users will be set to inactive by default, consider using the User.is_active field in your LOGIN_REDIRECT_URL view to notifying the user of their status.
For details, see testapp/ssltest/settings.py
Optional Configuration
If you want to use the standard login url, set SSLCLIENT_LOGIN_URL = None or leave it undefined. For cases where you want a seperate login URL for SSL auth, set SSLCLIENT_LOGIN_URL = “/YOUR_URL/”. SSLCLIENT_LOGIN_URL is designed for use cases where some users login via the regular Django login without using SSLCLIENT auth, but you have a seperate login URL for users that login with SSLCLIENT auth.
If you want to allow insecure request (eg. your django app is behind a proxy or load balancer) set SSLCLIENT_ALLOW_INSECURE_REQUEST = True. If not set, secure connection will be required by default.
Smart Card support
For (Finnish) instructions see doc/fineid/FINEID.md
TODO
Active directory integration.
How to get help
Please do ask your questions on http://stackoverflow.com/ I am active there, and more likely to answer you publicly. Also, you can try catching TheJoey on #django@freenode
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
File details
Details for the file django-ssl-auth-2.2.0.tar.gz
.
File metadata
- Download URL: django-ssl-auth-2.2.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a06cc247bfc4511e9850fc0d198e356f1460a533a187f7052df28dc1f8d02ace |
|
MD5 | 8720a2fb2ba590db03b1257ce0fe6ed0 |
|
BLAKE2b-256 | 9da25c8b6aaf5553c0f3b865709cbfd8cbdc9f02e1973cca3983db370615b77d |