]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
PHP_AUTH_USER isn't available when using php as cgi
authorNicolas Lœuillet <nicolas.loeuillet@gmail.com>
Mon, 23 Dec 2013 08:09:10 +0000 (09:09 +0100)
committerNicolas Lœuillet <nicolas.loeuillet@gmail.com>
Mon, 23 Dec 2013 08:09:10 +0000 (09:09 +0100)
inc/poche/Poche.class.php
index.php

index adec9b288714c4424d59bf1d1289c0349a578c59..4b26574d08433c194bfacce40daadb20fd3bcc46 100644 (file)
@@ -446,7 +446,7 @@ class Poche
                 $themes = $this->getInstalledThemes();
                 $languages = $this->getInstalledLanguages();
                 $token = $this->user->getConfigValue('token');
-                $http_auth = (isset($_SERVER['PHP_AUTH_USER']))?true:false;
+                $http_auth = (isset($_SERVER['PHP_AUTH_USER']) || isset($_SERVER['REMOTE_USER'])) ? true : false;
                 $tpl_vars = array(
                     'themes' => $themes,
                     'languages' => $languages,
@@ -649,14 +649,18 @@ class Poche
      * it redirects the user to the $referer link
      * @return array
      */
-     private function credentials() {
-         if(isset($_SERVER['PHP_AUTH_USER'])) {
-             return array($_SERVER['PHP_AUTH_USER'],'php_auth');
-         }
-         if(!empty($_POST['login']) && !empty($_POST['password'])) {
-             return array($_POST['login'],$_POST['password']);
-         }
-         return array(false,false);
+    private function credentials() {
+        if(isset($_SERVER['PHP_AUTH_USER'])) {
+            return array($_SERVER['PHP_AUTH_USER'],'php_auth');
+        }
+        if(!empty($_POST['login']) && !empty($_POST['password'])) {
+            return array($_POST['login'],$_POST['password']);
+        }
+        if(isset($_SERVER['REMOTE_USER'])) {
+            return array($_SERVER['REMOTE_USER'],'http_auth');
+        }
+        
+        return array(false,false);
      }
 
     /**
index 145da772f5ca28238e993dc79340518e2822d583..fb251298ed373e3e7bd35ea4dac53fcd487dd449 100644 (file)
--- a/index.php
+++ b/index.php
@@ -100,6 +100,15 @@ if (Session::isLogged()) {
         $tpl_file = Tools::getTplFile('login');
         $tpl_vars['http_auth'] = 1;
     }
+} elseif(isset($_SERVER['REMOTE_USER'])) {
+    if($poche->store->userExists($_SERVER['REMOTE_USER'])) {
+        $poche->login($referer);
+    } else {
+        $poche->messages->add('e', _('login failed: user doesn\'t exist'));
+        Tools::logm('user doesn\'t exist');
+        $tpl_file = Tools::getTplFile('login');
+        $tpl_vars['http_auth'] = 1;
+    }
 } else {
     $tpl_file = Tools::getTplFile('login');
     $tpl_vars['http_auth'] = 0;