setup django_browserid authentication

This commit is contained in:
mdoglio 2014-02-14 17:37:06 +00:00
Родитель 08105369ce
Коммит cda3c10da6
4 изменённых файлов: 25 добавлений и 87 удалений

Просмотреть файл

@ -91,7 +91,7 @@ AUTHENTICATION_BACKENDS = (
# this tells browserid to not create users.
# a user must be created first in the admin
# and then can be recognized with persona login
BROWSERID_CREATE_USER = False
BROWSERID_CREATE_USER = True
# Path to redirect to on successful login.
LOGIN_REDIRECT_URL = '/'

Просмотреть файл

@ -1,22 +1,25 @@
from django.contrib import admin
from treeherder.model.models import *
from django_browserid.admin import site as browserid_admin
class JobTypeAdmin(admin.ModelAdmin):
list_display = ['name', 'job_group', 'symbol', 'active_status']
list_editable = ['symbol', 'job_group']
admin.site.register(Product)
admin.site.register(BuildPlatform)
admin.site.register(Option)
admin.site.register(RepositoryGroup)
admin.site.register(Repository)
admin.site.register(MachinePlatform)
admin.site.register(Bugscache)
admin.site.register(Machine)
admin.site.register(MachineNote)
admin.site.register(Datasource)
admin.site.register(JobGroup)
admin.site.register(RepositoryVersion)
admin.site.register(OptionCollection)
admin.site.register(JobType, JobTypeAdmin)
admin.site.register(FailureClassification)
browserid_admin.register(Product)
browserid_admin.register(BuildPlatform)
browserid_admin.register(Option)
browserid_admin.register(RepositoryGroup)
browserid_admin.register(Repository)
browserid_admin.register(MachinePlatform)
browserid_admin.register(Bugscache)
browserid_admin.register(Machine)
browserid_admin.register(MachineNote)
browserid_admin.register(Datasource)
browserid_admin.register(JobGroup)
browserid_admin.register(RepositoryVersion)
browserid_admin.register(OptionCollection)
browserid_admin.register(JobType, JobTypeAdmin)
browserid_admin.register(FailureClassification)

Просмотреть файл

@ -1,69 +0,0 @@
{% extends "admin/base_site.html" %}
{% load browserid %}
{% load i18n admin_static %}
{% load url from future %}
{% block extrastyle %}{{ block.super }}
<link rel="stylesheet" type="text/css" href="{% static "admin/css/login.css" %}" />
<link rel="stylesheet" type="text/css" href="{% static "browserid/persona-buttons.css" %}" />
{% endblock %}
{% block extrahead %}{{ block.super }}{% browserid_info %}{% endblock %}
{% block bodyclass %}login{% endblock %}
{% block nav-global %}{% endblock %}
{% block content_title %}{% endblock %}
{% block breadcrumbs %}{% endblock %}
{% block content %}
{% if form.errors and not form.non_field_errors and not form.this_is_the_login_form.errors %}
<p class="errornote">
{% blocktrans count counter=form.errors.items|length %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
</p>
{% endif %}
{% if form.non_field_errors or form.this_is_the_login_form.errors %}
{% for error in form.non_field_errors|add:form.this_is_the_login_form.errors %}
<p class="errornote">
{{ error }}
</p>
{% endfor %}
{% endif %}
<div id="content-main">
<form action="{{ app_path }}" method="post" id="login-form">{% csrf_token %}
<div class="form-row">
{% if not form.this_is_the_login_form.errors %}{{ form.username.errors }}{% endif %}
<label for="id_username" class="required">{% trans 'Username:' %}</label> {{ form.username }}
</div>
<div class="form-row">
{% if not form.this_is_the_login_form.errors %}{{ form.password.errors }}{% endif %}
<label for="id_password" class="required">{% trans 'Password:' %}</label> {{ form.password }}
<input type="hidden" name="this_is_the_login_form" value="1" />
<input type="hidden" name="next" value="{{ next }}" />
</div>
{% url 'admin_password_reset' as password_reset_url %}
{% if password_reset_url %}
<div class="password-reset-link">
<a href="{{ password_reset_url }}">{% trans 'Forgotten your password or username?' %}</a>
</div>
{% endif %}
<div class="submit-row">
<label>&nbsp;</label><input type="submit" value="{% trans 'Log in' %}" />
<p>{% browserid_login text='Persona Login' color='dark' %}</p>
</div>
</form>
<script type="text/javascript">
document.getElementById('id_username').focus()
</script>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
{% browserid_js %}
</div>
{% endblock %}

Просмотреть файл

@ -6,11 +6,15 @@ from .api import urls as api_urls
admin.autodiscover()
from django_browserid.admin import site as browserid_admin
browserid_admin.copy_registry(admin.site)
urlpatterns = patterns('',
url(r'^api/', include(api_urls)),
url(r'^browserid/', include('django_browserid.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^admin/', include(browserid_admin.urls)),
url(r'^docs/', include('rest_framework_swagger.urls')),
url(r'', include('django_browserid.urls')),
# by default redirect all request on / to /ui/
url(r'^$', RedirectView.as_view(url='/ui/'))
)