diff --git a/horizon/templates/auth/_login_form.html b/horizon/templates/auth/_login_form.html
index b0618c3024..7cc1f419fb 100644
--- a/horizon/templates/auth/_login_form.html
+++ b/horizon/templates/auth/_login_form.html
@@ -59,6 +59,11 @@
{{ request.COOKIES.logout_reason }}
{% endif %}
+ {% if csrf_failure %}
+
+ {% endif %}
{% if next %}
{% endif %}
diff --git a/openstack_auth/views.py b/openstack_auth/views.py
index 5e7fad4f60..769e594650 100644
--- a/openstack_auth/views.py
+++ b/openstack_auth/views.py
@@ -90,6 +90,8 @@ def login(request, template_name=None, extra_context=None, **kwargs):
if extra_context is None:
extra_context = {'redirect_field_name': auth.REDIRECT_FIELD_NAME}
+ extra_context['csrf_failure'] = request.GET.get('csrf_failure')
+
if not template_name:
if request.is_ajax():
template_name = 'auth/_login.html'
diff --git a/openstack_dashboard/settings.py b/openstack_dashboard/settings.py
index 6a469ccc41..b65e643f4d 100644
--- a/openstack_dashboard/settings.py
+++ b/openstack_dashboard/settings.py
@@ -214,6 +214,8 @@ SESSION_COOKIE_MAX_SIZE = 4093
# https://bugs.launchpad.net/horizon/+bug/1349463
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
+CSRF_FAILURE_VIEW = 'openstack_dashboard.views.csrf_failure'
+
LANGUAGES = (
('cs', 'Czech'),
('de', 'German'),
diff --git a/openstack_dashboard/views.py b/openstack_dashboard/views.py
index f91a30fb84..a1354b6808 100644
--- a/openstack_dashboard/views.py
+++ b/openstack_dashboard/views.py
@@ -17,7 +17,9 @@ import logging
from django.conf import settings
from django.core import urlresolvers
+from django import http
from django import shortcuts
+from django.utils.translation import ugettext as _
import django.views.decorators.vary
from django.views.generic import TemplateView
from six.moves import urllib
@@ -118,3 +120,14 @@ class ExtensibleHeaderView(TemplateView):
context['header_sections'] = header_sections
return context
+
+
+def csrf_failure(request, reason=""):
+ if reason:
+ reason += " "
+ reason += _("Cookies may be turned off. "
+ "Make sure cookies are enabled and try again.")
+
+ url = settings.LOGIN_URL + "?csrf_failure=%s" % urllib.parse.quote(reason)
+ response = http.HttpResponseRedirect(url)
+ return response