Skip to content
Snippets Groups Projects
Unverified Commit 9a2786d8 authored by Jaime Pérez Crespo's avatar Jaime Pérez Crespo Committed by GitHub
Browse files

Merge pull request #979 from Wittev1/feature/allowed-assertion-offset

Create a setting for the allowed assertion offset
parents 0e0f34f0 f2c960fd
No related branches found
No related tags found
No related merge requests found
......@@ -176,6 +176,16 @@ $config = [
*/
'enable.http_post' => false,
/*
* Set the allowed clock skew between encrypting/decrypting assertions
*
* If you have an server that is constantly out of sync, this option
* allows you to adjust the allowed clock-skew.
*
* Allowed range: 180 - 300
* Defaults to 180.
*/
'assertion.allowed_clock_skew' => 180,
/************************
......
......@@ -646,20 +646,30 @@ class Message
$currentURL = \SimpleSAML\Utils\HTTP::getSelfURLNoQuery();
// check various properties of the assertion
$config = \SimpleSAML\Configuration::getInstance();
$allowed_clock_skew = $config->getInteger('assertion.allowed_clock_skew', 180);
$options = [
'options' => [
'default' => 180,
'min_range' => 180,
'max_range' => 300,
],
];
$allowed_clock_skew = filter_var($allowed_clock_skew, FILTER_VALIDATE_INT, $options);
$notBefore = $assertion->getNotBefore();
if ($notBefore !== null && $notBefore > time() + 60) {
if ($notBefore !== null && $notBefore > time() + $allowed_clock_skew) {
throw new \SimpleSAML\Error\Exception(
'Received an assertion that is valid in the future. Check clock synchronization on IdP and SP.'
);
}
$notOnOrAfter = $assertion->getNotOnOrAfter();
if ($notOnOrAfter !== null && $notOnOrAfter <= time() - 60) {
if ($notOnOrAfter !== null && $notOnOrAfter <= time() - $allowed_clock_skew) {
throw new \SimpleSAML\Error\Exception(
'Received an assertion that has expired. Check clock synchronization on IdP and SP.'
);
}
$sessionNotOnOrAfter = $assertion->getSessionNotOnOrAfter();
if ($sessionNotOnOrAfter !== null && $sessionNotOnOrAfter <= time() - 60) {
if ($sessionNotOnOrAfter !== null && $sessionNotOnOrAfter <= time() - $allowed_clock_skew) {
throw new \SimpleSAML\Error\Exception(
'Received an assertion with a session that has expired. Check clock synchronization on IdP and SP.'
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment