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': ...@@ -339,7 +339,6 @@ if get_env_variable('DJANGO_SAML', 'FALSE') == 'TRUE':
'django.contrib.auth.backends.ModelBackend', 'django.contrib.auth.backends.ModelBackend',
'djangosaml2.backends.Saml2Backend', 'djangosaml2.backends.Saml2Backend',
) )
LOGIN_URL = '/saml2/login/'
remote_metadata = join(SITE_ROOT, 'remote_metadata.xml') remote_metadata = join(SITE_ROOT, 'remote_metadata.xml')
if not isfile(remote_metadata): if not isfile(remote_metadata):
...@@ -388,7 +387,7 @@ if get_env_variable('DJANGO_SAML', 'FALSE') == 'TRUE': ...@@ -388,7 +387,7 @@ if get_env_variable('DJANGO_SAML', 'FALSE') == 'TRUE':
'DJANGO_SAML_GROUP_OWNER_ATTRIBUTES', '').split(',') 'DJANGO_SAML_GROUP_OWNER_ATTRIBUTES', '').split(',')
SAML_CREATE_UNKNOWN_USER = True 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( SAML_ORG_ID_ATTRIBUTE = get_env_variable(
'DJANGO_SAML_ORG_ID_ATTRIBUTE') 'DJANGO_SAML_ORG_ID_ATTRIBUTE')
......
...@@ -6,7 +6,8 @@ from django.shortcuts import redirect ...@@ -6,7 +6,8 @@ from django.shortcuts import redirect
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from circle.settings.base import get_env_variable from circle.settings.base import get_env_variable
from dashboard.forms import CircleAuthenticationForm from dashboard.views import circle_login
admin.autodiscover() admin.autodiscover()
...@@ -24,8 +25,7 @@ urlpatterns = patterns( ...@@ -24,8 +25,7 @@ urlpatterns = patterns(
url(r'^admin/', include(admin.site.urls)), url(r'^admin/', include(admin.site.urls)),
url(r'^network/', include('network.urls')), url(r'^network/', include('network.urls')),
url(r'^dashboard/', include('dashboard.urls')), url(r'^dashboard/', include('dashboard.urls')),
url(r'^accounts/login/?$', 'django.contrib.auth.views.login', url(r'^accounts/login/?$', circle_login, name="accounts.login"),
{'authentication_form': CircleAuthenticationForm}),
url(r'^accounts/', include('django.contrib.auth.urls')), url(r'^accounts/', include('django.contrib.auth.urls')),
) )
......
...@@ -5,7 +5,9 @@ import re ...@@ -5,7 +5,9 @@ import re
from datetime import datetime from datetime import datetime
import requests import requests
from django.conf import settings
from django.contrib.auth.models import User, Group from django.contrib.auth.models import User, Group
from django.contrib.auth.views import login
from django.contrib.messages import warning from django.contrib.messages import warning
from django.core.exceptions import ( from django.core.exceptions import (
PermissionDenied, SuspiciousOperation, PermissionDenied, SuspiciousOperation,
...@@ -29,7 +31,7 @@ from braces.views import LoginRequiredMixin, SuperuserRequiredMixin ...@@ -29,7 +31,7 @@ from braces.views import LoginRequiredMixin, SuperuserRequiredMixin
from .forms import ( from .forms import (
VmCustomizeForm, TemplateForm, LeaseForm, NodeForm, HostForm, VmCustomizeForm, TemplateForm, LeaseForm, NodeForm, HostForm,
DiskAddForm, DiskAddForm, CircleAuthenticationForm,
) )
from .tables import (VmListTable, NodeListTable, NodeVmListTable, from .tables import (VmListTable, NodeListTable, NodeVmListTable,
TemplateListTable, LeaseListTable, GroupListTable,) TemplateListTable, LeaseListTable, GroupListTable,)
...@@ -1718,3 +1720,12 @@ class VmMigrateView(SuperuserRequiredMixin, TemplateView): ...@@ -1718,3 +1720,12 @@ class VmMigrateView(SuperuserRequiredMixin, TemplateView):
messages.error(self.request, _("You didn't select a node!")) messages.error(self.request, _("You didn't select a node!"))
return redirect("%s#activity" % vm.get_absolute_url()) 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 @@ ...@@ -18,7 +18,7 @@
margin-top: 40px; margin-top: 40px;
} }
.container { .container {
width: 400px; width: 600px;
} }
ul, li { ul, li {
...@@ -38,7 +38,13 @@ ...@@ -38,7 +38,13 @@
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 { .login-form {
margin-top: 40px;
padding: 0 10px; padding: 0 10px;
} }
......
...@@ -4,17 +4,32 @@ ...@@ -4,17 +4,32 @@
{% get_current_language as LANGUAGE_CODE %} {% get_current_language as LANGUAGE_CODE %}
{% block content %} {% block content %}
<div class="row"> <div class="row">
<div class="login-form">
{% if form.password.errors or form.username.errors %} {% if form.password.errors or form.username.errors %}
<div class="login-form-errors">
{% include "display-form-errors.html" %} {% include "display-form-errors.html" %}
</div>
{% endif %} {% endif %}
<h3>{% trans "Please login to continue!" %}</h3> <div class="col-sm-6">
<div class="login-form">
<form action="" method="POST"> <form action="" method="POST">
{% csrf_token %} {% csrf_token %}
{% crispy form %} {% crispy form %}
</form> </form>
<a class="pull-right" href="">Forgot your password?</a>
</div> </div>
</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 %} {% 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