diff --git a/application/security/LoginManager.php b/application/security/LoginManager.php index d6784d6..5a58926 100644 --- a/application/security/LoginManager.php +++ b/application/security/LoginManager.php @@ -58,6 +58,9 @@ class LoginManager */ public function generateStaySignedInToken($clientIpAddress) { + if ($this->configManager->get('security.session_protection_disabled') === true) { + $clientIpAddress = ''; + } $this->staySignedInToken = sha1( $this->configManager->get('credentials.hash') . $clientIpAddress diff --git a/tests/security/LoginManagerTest.php b/tests/security/LoginManagerTest.php index f26cd1e..b9ab5ec 100644 --- a/tests/security/LoginManagerTest.php +++ b/tests/security/LoginManagerTest.php @@ -259,6 +259,20 @@ class LoginManagerTest extends TestCase ); } + /** + * Generate a token depending on the user credentials with session protected disabled + */ + public function testGenerateStaySignedInTokenSessionProtectionDisabled() + { + $this->configManager->set('security.session_protection_disabled', true); + $this->loginManager->generateStaySignedInToken($this->clientIpAddress); + + $this->assertEquals( + sha1($this->passwordHash . $this->salt), + $this->loginManager->getStaySignedInToken() + ); + } + /** * Check user login - Shaarli has not yet been configured */