]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge commit 'jeff-themovie/private-rss' into 0.8.x
authorCraig Andrews <candrews@integralblue.com>
Wed, 22 Jul 2009 14:25:22 +0000 (10:25 -0400)
committerCraig Andrews <candrews@integralblue.com>
Wed, 22 Jul 2009 14:25:22 +0000 (10:25 -0400)
index.php
lib/common.php
lib/rssaction.php

index 5f9a048f2c7225917dcc56bfbb1b7326067ef4f9..69c0bc1b23275e53b0b9289f37529edb4135b660 100644 (file)
--- a/index.php
+++ b/index.php
@@ -165,7 +165,8 @@ function main()
 
     if (!$user && common_config('site', 'private') &&
         !in_array($action, array('login', 'openidlogin', 'finishopenidlogin',
-                                 'recoverpassword', 'api', 'doc', 'register'))) {
+                                 'recoverpassword', 'api', 'doc', 'register')) &&
+        !preg_match('/rss$/', $action)) {
         common_redirect(common_local_url('login'));
         return;
     }
index 9d7954fa984c8fb840881d91265ee1da302d8e5d..764c5a07702bdf8f87250ec10402cff1eff12a0c 100644 (file)
@@ -19,7 +19,7 @@
 
 if (!defined('LACONICA')) { exit(1); }
 
-define('LACONICA_VERSION', '0.8.1dev');
+define('LACONICA_VERSION', '0.9.0dev');
 
 define('AVATAR_PROFILE_SIZE', 96);
 define('AVATAR_STREAM_SIZE', 48);
index 9898894edd678e8fafd6a09c7d829cb2073672d2..6c982705efaea13508eaf634143427aab159eada 100644 (file)
@@ -97,6 +97,31 @@ class Rss10Action extends Action
     {
         // Parent handling, including cache check
         parent::handle($args);
+
+        if (common_config('site', 'private')) {
+            if (!isset($_SERVER['PHP_AUTH_USER'])) {
+
+                # This header makes basic auth go
+                header('WWW-Authenticate: Basic realm="Laconica RSS"');
+
+                # If the user hits cancel -- bam!
+                $this->show_basic_auth_error();
+                return;
+            } else {
+                $nickname = $_SERVER['PHP_AUTH_USER'];
+                $password = $_SERVER['PHP_AUTH_PW'];
+
+                if (!common_check_user($nickname, $password)) {
+                    # basic authentication failed
+                    list($proxy, $ip) = common_client_ip();
+
+                    common_log(LOG_WARNING, "Failed RSS auth attempt, nickname = $nickname, proxy = $proxy, ip = $ip.");
+                    $this->show_basic_auth_error();
+                    return;
+                }
+            }
+        }
+
         // Get the list of notices
         if (empty($this->tag)) {
             $this->notices = $this->getNotices($this->limit);
@@ -106,6 +131,18 @@ class Rss10Action extends Action
         $this->showRss();
     }
 
+    function show_basic_auth_error()
+    {
+        header('HTTP/1.1 401 Unauthorized');
+        header('Content-Type: application/xml; charset=utf-8');
+        $this->startXML();
+        $this->elementStart('hash');
+        $this->element('error', null, 'Could not authenticate you.');
+        $this->element('request', null, $_SERVER['REQUEST_URI']);
+        $this->elementEnd('hash');
+        $this->endXML();
+    }
+
     /**
      * Get the notices to output in this stream
      *