From 4d1f9f0f725899b640bd9f8c731aef559ab307b9 Mon Sep 17 00:00:00 2001 From: Howard Johnson Date: Oct 05 2016 12:31:25 +0000 Subject: Retain transaction ID through 401 pages If we get a 401 during a transaction (i.e. failing authentication), ipsilon shows the 401 error page, which has a link back to the login page. Clicking this link causes a new transaction to be created, losing any in-progress service provider authentication, and not redirecting back to the SP after a successful transaction. If we hit the 401 page and there's a current transaction, add the transaction ID to the link back to the login page, so the current transaction is preserved. Signed-off-by: Howard Johnson --- diff --git a/ipsilon/util/errors.py b/ipsilon/util/errors.py index c22b7f9..0e076fa 100644 --- a/ipsilon/util/errors.py +++ b/ipsilon/util/errors.py @@ -1,6 +1,7 @@ # Copyright (C) 2014 Ipsilon project Contributors, for license see COPYING from ipsilon.util.page import Page +import cherrypy class Errors(Page): @@ -34,8 +35,13 @@ class Error_400(Errors): class Error_401(Errors): def handler(self, status, message, traceback, version): + try: + tid = self.get_valid_transaction('login').transaction_id + except cherrypy.HTTPError: + tid = None return self._error_template('unauthorized.html', - title='Unauthorized', message=message) + title='Unauthorized', message=message, + ipsilon_transaction_id=tid) class Error_404(Errors): diff --git a/templates/unauthorized.html b/templates/unauthorized.html index cdb34da..abddb8c 100644 --- a/templates/unauthorized.html +++ b/templates/unauthorized.html @@ -7,6 +7,10 @@ {% else %}

Authentication was not successful

{% endif %} + {% if ipsilon_transaction_id %} +

Try to login again

+ {% else %}

Try to login again

+ {% endif %} {% endblock %}