aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2018-07-17 14:13:37 +0200
committerArthurHoaro <arthur@hoa.ro>2018-07-17 14:13:37 +0200
commitd9ba1cdd44a7eec9e7f4d429087c6ba838ad473e (patch)
tree5be107b1b06cc9fbaeec32679474816d6469748e
parent5d32c50ad70a659a6c86b80fa65d7ec41e045b1e (diff)
downloadShaarli-d9ba1cdd44a7eec9e7f4d429087c6ba838ad473e.tar.gz
Shaarli-d9ba1cdd44a7eec9e7f4d429087c6ba838ad473e.tar.zst
Shaarli-d9ba1cdd44a7eec9e7f4d429087c6ba838ad473e.zip
Do not check the IP address with session protection disabled
This allows the user to stay logged in if his IP changes. Fixes #1106
-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()