]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fixes login / logout when HTTP Basic Headers are avilable.
authorjosh4trunks <joshruehlig@gmail.com>
Mon, 24 Mar 2014 02:29:03 +0000 (19:29 -0700)
committerjosh4trunks <joshruehlig@gmail.com>
Fri, 4 Apr 2014 05:12:57 +0000 (22:12 -0700)
config/config.sample.php
lib/base.php

index adcc175e2fae886746d80100523c33db232d115f..8430b8d6539d5eb59642dcf1d90a7090938f115a 100755 (executable)
@@ -178,12 +178,12 @@ $CONFIG = array(
 /* Enable or disable the logging of IP addresses in case of webform auth failures */
 "log_authfailip" => false,
 
+<<<<<<< HEAD
 /* Whether ownCloud should log the last successfull cron exec */
 "cron_log" => true,
 
-/* Whether http-basic username must equal username to login */
-"basic_auth" => true,
-
+=======
+>>>>>>> Fixes login / logout when HTTP Basic Headers are avilable.
 /*
  * Configure the size in bytes log rotation should happen, 0 or false disables the rotation.
  * This rotates the current owncloud logfile to a new name, this way the total log usage
index 15a3ec8bc8aca22dce7af30dca55b9bf60989c06..2141695a93d6f1ff0eea68440270619fce3ae525 100644 (file)
@@ -538,17 +538,6 @@ class OC {
                OC_User::useBackend(new OC_User_Database());
                OC_Group::useBackend(new OC_Group_Database());
 
-               $basic_auth = OC_Config::getValue('basic_auth', true);
-               if ($basic_auth && isset($_SERVER['PHP_AUTH_USER']) && self::$session->exists('loginname')
-                       && $_SERVER['PHP_AUTH_USER'] !== self::$session->get('loginname')) {
-                       $sessionUser = self::$session->get('loginname');
-                       $serverUser = $_SERVER['PHP_AUTH_USER'];
-                       OC_Log::write('core',
-                               "Session loginname ($sessionUser) doesn't match SERVER[PHP_AUTH_USER] ($serverUser).",
-                               OC_Log::WARN);
-                       OC_User::logout();
-               }
-
                // Load minimum set of apps - which is filesystem, authentication and logging
                if (!self::checkUpgrade(false)) {
                        OC_App::loadApps(array('authentication'));
@@ -697,8 +686,10 @@ class OC {
                        self::checkUpgrade();
                }
 
-               // Test it the user is already authenticated using Apaches AuthType Basic... very usable in combination with LDAP
-               OC::tryBasicAuthLogin();
+               if (!OC_User::isLoggedIn()) {
+                       // Test it the user is already authenticated using Apaches AuthType Basic... very usable in combination with LDAP
+                       OC::tryBasicAuthLogin();
+               }
 
                if (!self::$CLI and (!isset($_GET["logout"]) or ($_GET["logout"] !== 'true'))) {
                        try {
@@ -749,6 +740,16 @@ class OC {
                                if (isset($_COOKIE['oc_token'])) {
                                        OC_Preferences::deleteKey(OC_User::getUser(), 'login_token', $_COOKIE['oc_token']);
                                }
+                               if (isset($_SERVER['PHP_AUTH_USER'])) {
+                                       $cookie_path = OC::$WEBROOT ? : '/';
+                                       if (isset($_COOKIE['oc_ignore_php_auth_user'])) {
+                                               // Ignore HTTP Authentication for 5 more mintues.
+                                               setcookie('oc_ignore_php_auth_user', '', time() + 300, $cookie_path);
+                                       } else {
+                                               // Ignore HTTP Aunthentication to allow a different user to log in.
+                                               setcookie('oc_ignore_php_auth_user', $_SERVER['PHP_AUTH_USER'], 0, $cookie_path);
+                                       }
+                               }
                                OC_User::logout();
                                // redirect to webroot and add slash if webroot is empty
                                header("Location: " . OC::$WEBROOT.(empty(OC::$WEBROOT) ? '/' : ''));
@@ -914,6 +915,7 @@ class OC {
        protected static function tryBasicAuthLogin() {
                if (!isset($_SERVER["PHP_AUTH_USER"])
                        || !isset($_SERVER["PHP_AUTH_PW"])
+                       || (isset($_COOKIE['oc_ignore_php_auth_user']) && $_COOKIE['oc_ignore_php_auth_user'] === $_SERVER['PHP_AUTH_USER'])
                ) {
                        return false;
                }