aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--application/security/LoginManager.php3
-rw-r--r--tests/security/LoginManagerTest.php14
2 files changed, 17 insertions, 0 deletions
diff --git a/application/security/LoginManager.php b/application/security/LoginManager.php
index d6784d6d..5a58926d 100644
--- a/application/security/LoginManager.php
+++ b/application/security/LoginManager.php
@@ -58,6 +58,9 @@ class LoginManager
58 */ 58 */
59 public function generateStaySignedInToken($clientIpAddress) 59 public function generateStaySignedInToken($clientIpAddress)
60 { 60 {
61 if ($this->configManager->get('security.session_protection_disabled') === true) {
62 $clientIpAddress = '';
63 }
61 $this->staySignedInToken = sha1( 64 $this->staySignedInToken = sha1(
62 $this->configManager->get('credentials.hash') 65 $this->configManager->get('credentials.hash')
63 . $clientIpAddress 66 . $clientIpAddress
diff --git a/tests/security/LoginManagerTest.php b/tests/security/LoginManagerTest.php
index f26cd1eb..b9ab5ec4 100644
--- a/tests/security/LoginManagerTest.php
+++ b/tests/security/LoginManagerTest.php
@@ -260,6 +260,20 @@ class LoginManagerTest extends TestCase
260 } 260 }
261 261
262 /** 262 /**
263 * Generate a token depending on the user credentials with session protected disabled
264 */
265 public function testGenerateStaySignedInTokenSessionProtectionDisabled()
266 {
267 $this->configManager->set('security.session_protection_disabled', true);
268 $this->loginManager->generateStaySignedInToken($this->clientIpAddress);
269
270 $this->assertEquals(
271 sha1($this->passwordHash . $this->salt),
272 $this->loginManager->getStaySignedInToken()
273 );
274 }
275
276 /**
263 * Check user login - Shaarli has not yet been configured 277 * Check user login - Shaarli has not yet been configured
264 */ 278 */
265 public function testCheckLoginStateNotConfigured() 279 public function testCheckLoginStateNotConfigured()