From 03ccb74052ccec209adedfcd9daf4648905b322b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 9 Jul 2009 18:22:46 -0400 Subject: [PATCH 1/4] 0.9.0 dev version --- lib/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common.php b/lib/common.php index 832667d81b..d3f7f1b2b4 100644 --- a/lib/common.php +++ b/lib/common.php @@ -19,7 +19,7 @@ if (!defined('LACONICA')) { exit(1); } -define('LACONICA_VERSION', '0.8.0'); +define('LACONICA_VERSION', '0.9.0dev'); define('AVATAR_PROFILE_SIZE', 96); define('AVATAR_STREAM_SIZE', 48); From ae6a3e258d58c863fb54c1c2b06a426fccb5a689 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Tue, 14 Jul 2009 03:45:12 +0800 Subject: [PATCH 2/4] Adds HTTP basic authentication for private RSS 1.0 feeds --- index.php | 3 ++- lib/rssaction.php | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index 5f9a048f2c..69c0bc1b23 100644 --- 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; } diff --git a/lib/rssaction.php b/lib/rssaction.php index fe3fd6f4a2..dceabcbec8 100644 --- a/lib/rssaction.php +++ b/lib/rssaction.php @@ -96,6 +96,28 @@ 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 + $this->show_basic_auth_error(); + return; + } + } + } + // Get the list of notices if (empty($this->tag)) { $this->notices = $this->getNotices($this->limit); @@ -105,6 +127,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 * From 7cfb2f569dbda8ef84149604cec88b2349d95306 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 9 Jul 2009 18:22:46 -0400 Subject: [PATCH 3/4] 0.9.0 dev version --- lib/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common.php b/lib/common.php index 9d7954fa98..764c5a0770 100644 --- a/lib/common.php +++ b/lib/common.php @@ -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); From 5015505f16c9ce412e6f5535f80188f33d24c4ea Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Fri, 17 Jul 2009 16:44:14 +0800 Subject: [PATCH 4/4] Added failed auth logging (like in actions/api.php) --- lib/rssaction.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/rssaction.php b/lib/rssaction.php index dceabcbec8..15c238bf90 100644 --- a/lib/rssaction.php +++ b/lib/rssaction.php @@ -112,6 +112,9 @@ class Rss10Action extends Action 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; }