Commit 5e443754 by Kálmán Viktor

dashboard: new login with saml2

parent cda740cf
......@@ -339,7 +339,6 @@ if get_env_variable('DJANGO_SAML', 'FALSE') == 'TRUE':
'django.contrib.auth.backends.ModelBackend',
'djangosaml2.backends.Saml2Backend',
)
LOGIN_URL = '/saml2/login/'
remote_metadata = join(SITE_ROOT, 'remote_metadata.xml')
if not isfile(remote_metadata):
......@@ -388,7 +387,7 @@ if get_env_variable('DJANGO_SAML', 'FALSE') == 'TRUE':
'DJANGO_SAML_GROUP_OWNER_ATTRIBUTES', '').split(',')
SAML_CREATE_UNKNOWN_USER = True
if get_env_variable('DJANGO_SAML_ORG_ID_ATTRIBUTE', False) != False:
if get_env_variable('DJANGO_SAML_ORG_ID_ATTRIBUTE', False) is not False:
SAML_ORG_ID_ATTRIBUTE = get_env_variable(
'DJANGO_SAML_ORG_ID_ATTRIBUTE')
......
......@@ -6,7 +6,8 @@ from django.shortcuts import redirect
from django.core.urlresolvers import reverse
from circle.settings.base import get_env_variable
from dashboard.forms import CircleAuthenticationForm
from dashboard.views import circle_login
admin.autodiscover()
......@@ -24,8 +25,7 @@ urlpatterns = patterns(
url(r'^admin/', include(admin.site.urls)),
url(r'^network/', include('network.urls')),
url(r'^dashboard/', include('dashboard.urls')),
url(r'^accounts/login/?$', 'django.contrib.auth.views.login',
{'authentication_form': CircleAuthenticationForm}),
url(r'^accounts/login/?$', circle_login, name="accounts.login"),
url(r'^accounts/', include('django.contrib.auth.urls')),
)
......
......@@ -5,7 +5,9 @@ import re
from datetime import datetime
import requests
from django.conf import settings
from django.contrib.auth.models import User, Group
from django.contrib.auth.views import login
from django.contrib.messages import warning
from django.core.exceptions import (
PermissionDenied, SuspiciousOperation,
......@@ -29,7 +31,7 @@ from braces.views import LoginRequiredMixin, SuperuserRequiredMixin
from .forms import (
VmCustomizeForm, TemplateForm, LeaseForm, NodeForm, HostForm,
DiskAddForm,
DiskAddForm, CircleAuthenticationForm,
)
from .tables import (VmListTable, NodeListTable, NodeVmListTable,
TemplateListTable, LeaseListTable, GroupListTable,)
......@@ -1718,3 +1720,12 @@ class VmMigrateView(SuperuserRequiredMixin, TemplateView):
messages.error(self.request, _("You didn't select a node!"))
return redirect("%s#activity" % vm.get_absolute_url())
def circle_login(request):
authentication_form = CircleAuthenticationForm
extra_context = {
'saml2': getattr(settings, "SAML_CONFIG", False)
}
return login(request, authentication_form=authentication_form,
extra_context=extra_context)
......@@ -18,7 +18,7 @@
margin-top: 40px;
}
.container {
width: 400px;
width: 600px;
}
ul, li {
......@@ -37,8 +37,14 @@
-moz-box-shadow: 0 1px 2px rgba(0,0,0,.15);
box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.login-form-errors .alert {
margin-right: 30px;
margin-left: 30px;
}
.login-form {
margin-top: 40px;
padding: 0 10px;
}
......
......@@ -4,17 +4,32 @@
{% get_current_language as LANGUAGE_CODE %}
{% block content %}
<div class="row">
<div class="login-form">
{% if form.password.errors or form.username.errors %}
<div class="row">
{% if form.password.errors or form.username.errors %}
<div class="login-form-errors">
{% include "display-form-errors.html" %}
{% endif %}
<h3>{% trans "Please login to continue!" %}</h3>
</div>
{% endif %}
<div class="col-sm-6">
<div class="login-form">
<form action="" method="POST">
{% csrf_token %}
{% crispy form %}
</form>
<a class="pull-right" href="">Forgot your password?</a>
</div>
</div>
<div class="col-sm-6">
<h4 style="padding-top: 0; margin-top: 0;">Login with eduID</h4>
{% if saml2 %}
<a href="{% url "saml2_login" %}">Click here!</a>
{% else %}
{% trans "SAML2 NOT AVAILABLE" %}
{% endif %}
</div>
</div>
<div class="row">
<div class="col-sm-12">
<a class="pull-right" href="">Forgot your password?</a>
</div>
</div>
{% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment