diff --git a/.github/build/full.json b/.github/build/full.json index f9c96cb9f0..186a559602 100644 --- a/.github/build/full.json +++ b/.github/build/full.json @@ -6,7 +6,7 @@ }, "consent": { "repository": "simplesamlphp/simplesamlphp-module-consent", - "version": "~1.5.0" + "version": "~1.6.1" }, "consentadmin": { "repository": "simplesamlphp/simplesamlphp-module-consentadmin", diff --git a/composer.json b/composer.json index 597aeb018d..6f66c15f8b 100644 --- a/composer.json +++ b/composer.json @@ -74,7 +74,7 @@ "simplesamlphp/composer-module-installer": "~1.7", "simplesamlphp/saml2": "~6.1", "simplesamlphp/saml2-legacy": "~4.20", - "simplesamlphp/simplesamlphp-assets-base": "~2.5.0", + "simplesamlphp/simplesamlphp-assets-base": "~2.6.0", "simplesamlphp/xml-common": "~2.7", "simplesamlphp/xml-security": "~2.3", "symfony/cache": "~7.4", @@ -157,5 +157,5 @@ "echo 'Post-install tasks completed!'" ] }, - "version": "v2.5.5" + "version": "v2.6.0" } diff --git a/composer.lock b/composer.lock index 085e6c9ad7..b17f4dc5c9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4e6857443d39c56d9dd53c6befc9ff6a", + "content-hash": "9bd7d5b513f31ecd95ff97a28ef037d2", "packages": [ { "name": "gettext/gettext", @@ -1314,16 +1314,16 @@ }, { "name": "simplesamlphp/simplesamlphp-assets-base", - "version": "v2.5.15", + "version": "v2.6.1", "source": { "type": "git", "url": "https://github.com/simplesamlphp/simplesamlphp-assets-base.git", - "reference": "6c65cfe90415e2922a9a2ace2bbb72761525fa35" + "reference": "7ddfc3685dd7656ee1350d9d5ad1df0278e92ae5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/simplesamlphp/simplesamlphp-assets-base/zipball/6c65cfe90415e2922a9a2ace2bbb72761525fa35", - "reference": "6c65cfe90415e2922a9a2ace2bbb72761525fa35", + "url": "https://api.github.com/repos/simplesamlphp/simplesamlphp-assets-base/zipball/7ddfc3685dd7656ee1350d9d5ad1df0278e92ae5", + "reference": "7ddfc3685dd7656ee1350d9d5ad1df0278e92ae5", "shasum": "" }, "require": { @@ -1344,9 +1344,9 @@ "description": "Assets for the SimpleSAMLphp main repository", "support": { "issues": "https://github.com/simplesamlphp/simplesamlphp-assets-base/issues", - "source": "https://github.com/simplesamlphp/simplesamlphp-assets-base/tree/v2.5.15" + "source": "https://github.com/simplesamlphp/simplesamlphp-assets-base/tree/v2.6.1" }, - "time": "2026-05-31T03:32:51+00:00" + "time": "2026-05-31T18:56:52+00:00" }, { "name": "simplesamlphp/xml-common", diff --git a/config/config.php.dist b/config/config.php.dist index 3fb78ff2d1..70c0f0c5a3 100644 --- a/config/config.php.dist +++ b/config/config.php.dist @@ -606,6 +606,15 @@ $config = [ */ 'session.datastore.timeout' => (4 * 60 * 60), // 4 hours + /* + * The datastore within a session can contain an arbitrary number of login and logout requests, as well as + * error reports. Historically, this is unlimited, which can result in very large sessions if a user agent makes + * repeated and frequent requests. + * Setting a limit here ensures older objects are discarded as new ones are added. A value of 25 is recommended as + * this should not cause any real inconvenience, but limits the maximum size of a session. + */ + 'session.datastore.limit' => 0, // no limit + /* * Sets the duration, in seconds, auth state should be stored. */ diff --git a/docs/simplesamlphp-changelog.md b/docs/simplesamlphp-changelog.md index 4f2e67cbd3..bc0fe97bef 100644 --- a/docs/simplesamlphp-changelog.md +++ b/docs/simplesamlphp-changelog.md @@ -5,6 +5,17 @@ This document lists the changes between versions of SimpleSAMLphp. See the [upgrade notes](https://simplesamlphp.org/docs/stable/simplesamlphp-upgrade-notes.html) for specific information about upgrading. +## Version 2.6.0 + +Release TBD + +* Support for session.datastore.limit configuration setting (#2670) +* Change the response-code for unknown authsource from 500 > 404 + +`consent` + +* Added support for Redis as backend for storing consent (v1.6.0) + ## Version 2.5.6 Released TBD diff --git a/extra/simplesamlphp.spec b/extra/simplesamlphp.spec index 9c18fc6bdc..8469a2100d 100644 --- a/extra/simplesamlphp.spec +++ b/extra/simplesamlphp.spec @@ -1,6 +1,6 @@ %define name simplesamlphp %define summary SAML IDP/SP written in PHP -%define version 2.5.5 +%define version 2.6.0 %define release 1 %define license LGPL 2.1 %define group Networking/WWW diff --git a/src/SimpleSAML/Error/AuthSource.php b/src/SimpleSAML/Error/AuthSource.php index 4cd207bc81..1417490a98 100644 --- a/src/SimpleSAML/Error/AuthSource.php +++ b/src/SimpleSAML/Error/AuthSource.php @@ -4,6 +4,7 @@ namespace SimpleSAML\Error; +use Symfony\Component\HttpFoundation\Response; use Throwable; /** @@ -36,6 +37,7 @@ public function __construct( '%REASON%' => $this->reason, ], $cause, + Response::HTTP_NOT_FOUND, ); $this->message = "Error with authentication source '$authsource': $reason"; diff --git a/src/SimpleSAML/Session.php b/src/SimpleSAML/Session.php index c94d785bae..a339e32e73 100644 --- a/src/SimpleSAML/Session.php +++ b/src/SimpleSAML/Session.php @@ -946,10 +946,33 @@ public function setData(string $type, string $id, mixed $data, int|string|null $ $this->dataStore[$type][$id] = $dataInfo; + $this->maintainDataStoreLimit($type); + $this->markDirty(); } + /** + * This ensures that the number of elements in a data store does not exceed configured limits + * and trims it until the limit is not exceeded, removing elements from the start of the array + */ + private function maintainDataStoreLimit(string $type): void + { + $limit = self::$config->getOptionalInteger('session.datastore.limit', 0); + if ($limit <= 0) { + return; + } + if (!array_key_exists($type, $this->dataStore)) { + return; + } + $count = count($this->dataStore[$type]); + while ($count > $limit) { + array_shift($this->dataStore[$type]); + $count--; + } + } + + /** * This function removes expired data from the data store. * diff --git a/tests/src/SimpleSAML/SessionTest.php b/tests/src/SimpleSAML/SessionTest.php index c6d943fba0..2c804b7f57 100644 --- a/tests/src/SimpleSAML/SessionTest.php +++ b/tests/src/SimpleSAML/SessionTest.php @@ -134,4 +134,31 @@ public function testGetDataWithExpiredSessionKey(bool $allowedExpired, string|in $this->assertNull($fetchedData); } } + + + public function testDataStoreLimit() + { + $session = Session::getSessionFromRequest(); + + //for this test, we set a datastore limit + $config = Configuration::loadFromArray(['session.datastore.limit' => 3], '[ARRAY]', 'simplesaml'); + $session->setConfiguration($config); + + //set 3 values for a data type testType + $session->setData('testType', 'testKey1', 'data1'); + $session->setData('testType', 'testKey2', 'data2'); + $session->setData('testType', 'testKey3', 'data3'); + + //we still expect the first value to be present... + $this->assertEquals('data1', $this->session->getData('testType', 'testKey1')); + + //but if we add one more, it should get removed + $session->setData('testType', 'testKey4', 'data4'); + $this->assertNull($this->session->getData('testType', 'testKey1')); + + //verify the other expected values remain + $this->assertEquals('data2', $this->session->getData('testType', 'testKey2')); + $this->assertEquals('data3', $this->session->getData('testType', 'testKey3')); + $this->assertEquals('data4', $this->session->getData('testType', 'testKey4')); + } }