Browser ID is Mozillas new federated authentication system. This screencast walks you through using the django-browserid package to do your authentication, and attach it to the built in Django auth system
Code
Install django-browserid
$ pip install -e git+https://github.com/mozilla/django-browserid.git#egg=django-browserid
settings.py
INSTALLED_APPS = (
...
'django.contrib.auth',
'django_browserid',
...
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django_browserid.context_processors.browserid_form',
'django.contrib.auth.context_processors.auth',
)
AUTHENTICATION_BACKENDS = (
'django_browserid.auth.BrowserIDBackend',
)
SITE_URL = 'http://localhost:8000'
BROWSERID_CREATE_USER = True
urls.py
url(r'^browserid/', include('django_browserid.urls')),
template/base.html
<!DOCTYPE html>
<html>
<head>
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" type="text/css" href="/static/css/main.css" />
<script src="https://browserid.org/include.js" type="text/javascript"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script>
{% block head %}{% endblock %}
<script type="text/javascript">
$(document).ready(function() {
$('#browserid').bind('click', function(e) {
e.preventDefault();
navigator.id.getVerifiedEmail(function(assertion) {
if (assertion) {
var $e = $('#id_assertion');
$e.val(assertion.toString());
$e.parent().submit();
}
});
});
});
</script>
</head>
<body>
<div>
{% if not user.is_authenticated %}
<a id="browserid" href="#">Sign In</a>
<form method="POST" action="{% url browserid_verify %}">
{% csrf_token %}
{{ browserid_form.as_p }}
</form>
{% endif %}
</div>
{% if user.is_authenticated %}
Hello {{ user.email }}.
{% endif %}
<div id="main">
...
</div>
</body>
</html>