Skip to main content

Django app implementing TLS Authentication - simple client certificate CA inclusive

Project description

* Django-TLSAuth

Django-TLSAuth integrates a minimal certificate authority (CA) and
implements TLS client certificate authentication. It depends on nginx
for handling the TLS authentication part.

** Installation
#+BEGIN_SRC sh
pip install django_tlsauth
#+END_SRC
Django-TLSAuth depends on tlsauth which provides minimal tools to
act as a CA. Please follow the "CA and https service install" steps
from https://github.com/stef/tlsauth to set up your webserver and CA.

After setting up the CA, you should also configure it in django,
put something like this with adjusted paths into your settings.py:
#+BEGIN_SRC python
from tlsauth import CertAuthority

TLS_CA=CertAuthority('tlsauth/CA/public/root.pem',
'tlsauth/CA/private/root.pem',
'tlsauth/CA/conf/serial',
'tlsauth/CA/dummy.pem',
'http://www.example.com/crl.pem',
'tlsauth/CA/incoming',
)
TLS_ADMINGROUPS=['CA admins']
TLS_SCRUTINIZER=None # supply your own function authorizing automatic signatures
TLS_BLINDSIGN=False # blindly sign incoming CSRs
#+END_SRC

If you want to enable the admin to the mini-CA add to your urls.py
#+BEGIN_SRC python
url(r'^tlsauth/', include('django_tlsauth.urls')),
#+END_SRC


** tlsauth decorator
Django-TLSAuth provides a simple decorator to guard your entry points:
#+BEGIN_SRC python
from django.http import HttpResponse, HttpResponseRedirect
from django_tlsauth.views import tlsauth

def unauth(request):
return HttpResponseRedirect('/')

@tlsauth(unauth=unauth, groups=['helloworldophobians'])
def hello(request):
return HttpResponse("hello world")
#+END_SRC

** Managing certs
Django-TLSAuth provides a few default routes to manage the certs and
the CA.

*** /tlsauth/register/
Visitors can register like on a normal site, but when done, they get a
PKCS12 certificate ready to be saved and imported in all
browsers. This is totally automatic and there's no check if the
specified organization is not a privileged one (like "CA admins" in
the above example). This really provides no security, for bots and
scripts it's even easier to use these certs than for normal humans.
Other mechanisms must be deployed to provide meaningful authentication.

*** /tlsauth/certify/
Visitors can submit their Certificate Signing Request (can be easily
generated using gencert.sh from tlsauth), which depending on
configuration either returns automatically a signed certificate (no
meaningful authentication this way, avoid this!), or it gets stored
for later approval by the "CA admins".

*** /tlsauth/cert/
Returns the CA root certificate in PEM format, for import into your browser.


*** /tlsauth/csrs/
Displays a list of incoming CSRs to any certified member of the "CA
admin" group. The certs can be either rejected or signed, in the later
case the resulting certificate is sent to the email address of the
subject.

*** /tlsauth/test/
Displays whether you are TLS authenticated and what your distinguished name is.

Project details


Download files

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

Source Distribution

django_tlsauth-0.1.1.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

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

django_tlsauth-0.1.1-py2.7.egg (17.7 kB view details)

Uploaded Egg

File details

Details for the file django_tlsauth-0.1.1.tar.gz.

File metadata

File hashes

Hashes for django_tlsauth-0.1.1.tar.gz
Algorithm Hash digest
SHA256 de4c69f0e23ce62b3bfc7daa6f3fd7407ca11693bd2eddf12a10d613c341807e
MD5 5a2651d16ff1265bf19539aaf32ea009
BLAKE2b-256 d4a6195795fcd23c4a06074d782e6c6e677509b036258fc4679b6a822c7fdc24

See more details on using hashes here.

File details

Details for the file django_tlsauth-0.1.1-py2.7.egg.

File metadata

File hashes

Hashes for django_tlsauth-0.1.1-py2.7.egg
Algorithm Hash digest
SHA256 d9b8143fb82a73965a31408edd2a9b9fbd3666d00428c6b728f9cfc7068a7984
MD5 9086d624435f8f252614889cdb1fd066
BLAKE2b-256 b5bd9b8d94dac8034ec2b1094e0f6474a1194619cefd885ea17a343cef56daa1

See more details on using hashes here.

Supported by

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