Use $wgSecureCookie to decide whether to actually mark secure cookies as 'secure'
authorBrad Jorsch <bjorsch@wikimedia.org>
Mon, 25 Jan 2016 19:15:40 +0000 (14:15 -0500)
committerBrad Jorsch <bjorsch@wikimedia.org>
Mon, 25 Jan 2016 19:25:09 +0000 (14:25 -0500)
The pre-SessionManager code did this, and the change in combination with
the API not honoring forceHTTPS led to T124252.

Bug: T124252
Change-Id: Ic6a79fbb30491040facd7c200b1f47d6b99ce637

includes/session/CookieSessionProvider.php
tests/phpunit/includes/session/CookieSessionProviderTest.php

index 915127f..2d01d1d 100644 (file)
@@ -176,7 +176,10 @@ class CookieSessionProvider extends SessionProvider {
 
                $forceHTTPS = $session->shouldForceHTTPS() || $user->requiresHTTPS();
                if ( $forceHTTPS ) {
-                       $options['secure'] = true;
+                       // Don't set the secure flag if the request came in
+                       // over "http", for backwards compat.
+                       // @todo Break that backwards compat properly.
+                       $options['secure'] = $this->config->get( 'CookieSecure' );
                }
 
                $response->setCookie( $this->params['sessionName'], $session->getId(), null,
index ccf45f6..702f556 100644 (file)
@@ -431,7 +431,7 @@ class CookieSessionProviderTest extends MediaWikiTestCase {
                        'cookieOptions' => array( 'prefix' => 'x' ),
                ) );
                $config = $this->getConfig();
-               $config->set( 'CookieSecure', false );
+               $config->set( 'CookieSecure', $secure );
                $provider->setLogger( new \TestLogger() );
                $provider->setConfig( $config );
                $provider->setManager( SessionManager::singleton() );