Skip to content

Commit 6f33dc7

Browse files
doedjethijskh
authored andcommitted
Added the option to send users straight to selfserviceUrl when they don't have token with high enough LOA
In stead of throwing an error we send people to a nice readable page with information about how to get a token with the right LOA.
1 parent f995326 commit 6f33dc7

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

src/Controller/SFO.php

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,30 @@ public function acs(): Template
108108
$assertions = Message::processResponse($spMetadata, $idpMetadata, $response);
109109
} catch (Module\saml\Error $e) {
110110
// the status of the response wasn't "success"
111-
Logger::debug('SFO - status response received, showing error page.');
111+
$redirect = $idpMetadata->getOptionalBoolean('sfo:redirectToSelfserviceUrl', false);
112+
$selfserviceUrl = $idpMetadata->getOptionalString('sfo:selfserviceUrl', '');
112113

113-
$t = new Template($this->config, 'stepupsfo:handlestatus.twig');
114-
$t->data['status'] = $e->getStatus();
115-
$t->data['subStatus'] = $e->getSubStatus();
116-
$t->data['statusMessage'] = $e->getStatusMessage();
117-
$t->data['selfserviceUrl'] = $idpMetadata->getOptionalString('sfo:selfserviceUrl', '');
114+
if ($redirect &&
115+
!empty($selfserviceUrl) &&
116+
$e->getStatus() == 'urn:oasis:names:tc:SAML:2.0:status:Responder' &&
117+
$e->getSubStatus() == 'urn:oasis:names:tc:SAML:2.0:status:NoAuthnContext') {
118+
Logger::debug('SFO - token of demanded LOA is not available, redirecting to selfserviceUrl.');
118119

119-
return $t;
120-
}
120+
header('Location: '. $selfserviceUrl);
121+
exit();
122+
123+
} else {
124+
Logger::debug('SFO - status response received, showing error page.');
121125

126+
$t = new Template($this->config, 'stepupsfo:handlestatus.twig');
127+
$t->data['status'] = $e->getStatus();
128+
$t->data['subStatus'] = $e->getSubStatus();
129+
$t->data['statusMessage'] = $e->getStatusMessage();
130+
$t->data['selfserviceUrl'] = $selfserviceUrl;
131+
132+
return $t;
133+
}
134+
}
122135
Logger::debug('SFO - successful response received, resume processing');
123136
Auth\ProcessingChain::resumeProcessing($prestate);
124137
}

0 commit comments

Comments
 (0)