Skip to content

Commit f176724

Browse files
committed
Ensure compatibility with SSP >= 1.17
1 parent 13791b9 commit f176724

2 files changed

Lines changed: 56 additions & 11 deletions

File tree

templates/handlestatus.twig

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{% set pagetitle = 'Error while performing second factor authentication'|trans %}
2+
{% extends "base.twig" %}
3+
{% block content %}
4+
5+
<h2>{{ pagetitle }}</h2>
6+
7+
{% if status == "urn:oasis:names:tc:SAML:2.0:status:Responder" and subStatus == "urn:oasis:names:tc:SAML:2.0:status:AuthnFailed" %}
8+
9+
<p>{{ 'Authentication not successful:' | trans }}<br/><br/>
10+
11+
<strong>
12+
{{ statusMessage }}
13+
</strong></p>
14+
15+
{% elseif status == "urn:oasis:names:tc:SAML:2.0:status:Responder" and subStatus == "urn:oasis:names:tc:SAML:2.0:status:NoAuthnContext" %}
16+
17+
<p>{{ 'You could not be authenticated at the requested level.' | trans }}<br/>
18+
19+
{{ statusMessage }}</p>
20+
21+
<p>{{ 'Do you have a token registered with the required level?' | trans }}<br/><br/>
22+
{% trans %}Please go to the <a href="{{ selfserviceUrl }}">Selfservice Registration Portal</a>
23+
to review or enroll your token.{% endtrans %}</p>
24+
25+
{% else %}
26+
27+
<p>Unexpected error occurred while performing second factor authentication.<br/><br/>
28+
{{ status }}<br/>
29+
{{ subStatus }}<br/>
30+
{{ statusMessage }}</p>
31+
32+
<p>Please try again or contact your support desk.</p>
33+
34+
{% endif %}
35+
36+
{% endblock %}

www/acs.php

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@
77
* @package SimpleSAMLphp
88
*/
99

10+
function handleStatusResponse($exception, $selfserviceurl)
11+
{
12+
// the status of the response wasn't "success"
13+
SimpleSAML\Logger::debug('SFO - status response received, showing error page.');
14+
$config = SimpleSAML_Configuration::getInstance();
15+
16+
$t = new SimpleSAML_XHTML_Template($config, 'stepupsfo:handlestatus.php');
17+
$t->data['status'] = $exception->getStatus();
18+
$t->data['subStatus'] = $exception->getSubStatus();
19+
$t->data['statusMessage'] = $exception->getStatusMessage();
20+
$t->data['selfserviceUrl'] = $selfserviceurl;
21+
$t->show();
22+
exit();
23+
}
24+
1025
SimpleSAML\Logger::debug('SFO - receiving response');
1126

1227
$b = \SAML2\Binding::getCurrentBinding();
@@ -54,17 +69,11 @@
5469
try {
5570
$assertions = sspmod_saml_Message::processResponse($spMetadata, $idpMetadata, $response);
5671
} catch (sspmod_saml_Error $e) {
57-
// the status of the response wasn't "success"
58-
SimpleSAML\Logger::debug('SFO - status response received, showing error page.');
59-
$config = SimpleSAML_Configuration::getInstance();
60-
61-
$t = new SimpleSAML_XHTML_Template($config, 'stepupsfo:handlestatus.php');
62-
$t->data['status'] = $e->getStatus();
63-
$t->data['subStatus'] = $e->getSubStatus();
64-
$t->data['statusMessage'] = $e->getStatusMessage();
65-
$t->data['selfserviceUrl'] = $idpMetadata->getString('sfo:selfserviceUrl', '');
66-
$t->show();
67-
exit();
72+
// the status of the response wasn't "success" (SSP < 1.17)
73+
handleStatusResponse($e, $idpMetadata->getString('sfo:selfserviceUrl', ''));
74+
} catch (SimpleSAML\Module\saml\Error $e) {
75+
// the status of the response wasn't "success" (SSP >= 1.17)
76+
handleStatusResponse($e, $idpMetadata->getString('sfo:selfserviceUrl', ''));
6877
}
6978

7079
SimpleSAML\Logger::debug('SFO - successful response received, resume processing');

0 commit comments

Comments
 (0)