]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #1182 from ArthurHoaro/feature/session-protection-stay-login
authorArthurHoaro <arthur@hoa.ro>
Sat, 9 Feb 2019 11:36:31 +0000 (12:36 +0100)
committerGitHub <noreply@github.com>
Sat, 9 Feb 2019 11:36:31 +0000 (12:36 +0100)
Do not check the IP address with session protection disabled

application/security/LoginManager.php
tests/security/LoginManagerTest.php

index 0f3154835d734d74c035f169035d9d684b50dcfb..1ff3d0be84ad89bbdd9bec265569b53d3eef43cc 100644 (file)
@@ -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
index de8055edaede452cdeeb1c21ed42ae3b13447a8e..7b0262b32c128871841cf9d98aaf83e129ffacca 100644 (file)
@@ -260,6 +260,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
      */