summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/login.php11
-rw-r--r--actions/logout.php2
-rw-r--r--actions/public.php18
-rw-r--r--actions/register.php25
-rw-r--r--actions/xrds.php4
-rw-r--r--classes/User.php11
-rw-r--r--index.php3
-rw-r--r--lib/accountsettingsaction.php3
-rw-r--r--lib/logingroupnav.php5
-rw-r--r--lib/router.php9
-rw-r--r--lib/settingsaction.php6
-rw-r--r--lib/util.php3
-rw-r--r--plugins/OpenID/OpenIDPlugin.php199
-rw-r--r--plugins/OpenID/User_openid.php (renamed from classes/User_openid.php)13
-rw-r--r--plugins/OpenID/finishaddopenid.php (renamed from actions/finishaddopenid.php)2
-rw-r--r--plugins/OpenID/finishopenidlogin.php (renamed from actions/finishopenidlogin.php)2
-rw-r--r--plugins/OpenID/openid.php (renamed from lib/openid.php)2
-rw-r--r--plugins/OpenID/openidlogin.php (renamed from actions/openidlogin.php)2
-rw-r--r--plugins/OpenID/openidsettings.php (renamed from actions/openidsettings.php)2
-rw-r--r--plugins/OpenID/publicxrds.php (renamed from actions/publicxrds.php)2
20 files changed, 231 insertions, 93 deletions
diff --git a/actions/login.php b/actions/login.php
index 6f1b4777e..e09fdc76b 100644
--- a/actions/login.php
+++ b/actions/login.php
@@ -65,8 +65,6 @@ class LoginAction extends Action
*
* Switches on request method; either shows the form or handles its input.
*
- * Checks if only OpenID is allowed and redirects to openidlogin if so.
- *
* @param array $args $_REQUEST data
*
* @return void
@@ -75,9 +73,7 @@ class LoginAction extends Action
function handle($args)
{
parent::handle($args);
- if (common_config('site', 'openidonly')) {
- common_redirect(common_local_url('openidlogin'));
- } else if (common_is_real_login()) {
+ if (common_is_real_login()) {
$this->clientError(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->checkLogin();
@@ -254,11 +250,6 @@ class LoginAction extends Action
} else if (common_config('openid', 'enabled')) {
return _('Login with your username and password. ' .
'Don\'t have a username yet? ' .
- '[Register](%%action.register%%) a new account, or ' .
- 'try [OpenID](%%action.openidlogin%%). ');
- } else {
- return _('Login with your username and password. ' .
- 'Don\'t have a username yet? ' .
'[Register](%%action.register%%) a new account.');
}
}
diff --git a/actions/logout.php b/actions/logout.php
index 3fcfb4f4e..cb20a26b5 100644
--- a/actions/logout.php
+++ b/actions/logout.php
@@ -32,8 +32,6 @@ if (!defined('LACONICA')) {
exit(1);
}
-require_once INSTALLDIR.'/lib/openid.php';
-
/**
* Logout action class.
*
diff --git a/actions/public.php b/actions/public.php
index 2cf2e96e6..b68b2ff79 100644
--- a/actions/public.php
+++ b/actions/public.php
@@ -114,8 +114,6 @@ class PublicAction extends Action
{
parent::handle($args);
- header('X-XRDS-Location: '. common_local_url('publicxrds'));
-
$this->showPage();
}
@@ -157,22 +155,6 @@ class PublicAction extends Action
}
/**
- * Extra head elements
- *
- * We include a <meta> element linking to the publicxrds page, for OpenID
- * client-side authentication.
- *
- * @return void
- */
-
- function extraHead()
- {
- // for client side of OpenID authentication
- $this->element('meta', array('http-equiv' => 'X-XRDS-Location',
- 'content' => common_local_url('publicxrds')));
- }
-
- /**
* Show tabset for this page
*
* Uses the PublicGroupNav widget
diff --git a/actions/register.php b/actions/register.php
index 4654fad14..aa295c097 100644
--- a/actions/register.php
+++ b/actions/register.php
@@ -116,8 +116,6 @@ class RegisterAction extends Action
*
* Checks if registration is closed and shows an error if so.
*
- * Checks if only OpenID is allowed and redirects to openidlogin if so.
- *
* @param array $args $_REQUEST data
*
* @return void
@@ -129,8 +127,6 @@ class RegisterAction extends Action
if (common_config('site', 'closed')) {
$this->clientError(_('Registration not allowed.'));
- } else if (common_config('site', 'openidonly')) {
- common_redirect(common_local_url('openidlogin'));
} else if (common_logged_in()) {
$this->clientError(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
@@ -330,22 +326,11 @@ class RegisterAction extends Action
} else if ($this->error) {
$this->element('p', 'error', $this->error);
} else {
- if (common_config('openid', 'enabled')) {
- $instr =
- common_markup_to_html(_('With this form you can create '.
- ' a new account. ' .
- 'You can then post notices and '.
- 'link up to friends and colleagues. '.
- '(Have an [OpenID](http://openid.net/)? ' .
- 'Try our [OpenID registration]'.
- '(%%action.openidlogin%%)!)'));
- } else {
- $instr =
- common_markup_to_html(_('With this form you can create '.
- ' a new account. ' .
- 'You can then post notices and '.
- 'link up to friends and colleagues.'));
- }
+ $instr =
+ common_markup_to_html(_('With this form you can create '.
+ ' a new account. ' .
+ 'You can then post notices and '.
+ 'link up to friends and colleagues. '));
$this->elementStart('div', 'instructions');
$this->raw($instr);
diff --git a/actions/xrds.php b/actions/xrds.php
index 7518a5f70..b3aa8df8e 100644
--- a/actions/xrds.php
+++ b/actions/xrds.php
@@ -1,7 +1,7 @@
<?php
/**
- * XRDS for OpenID
+ * XRDS for OpenMicroBlogging
*
* PHP version 5
*
@@ -38,7 +38,7 @@ require_once INSTALLDIR.'/extlib/libomb/service_provider.php';
require_once INSTALLDIR.'/extlib/libomb/xrds_mapper.php';
/**
- * XRDS for OpenID
+ * XRDS for OpenMicroBlogging
*
* @category Action
* @package Laconica
diff --git a/classes/User.php b/classes/User.php
index bea47a3b0..104dfbacb 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -670,17 +670,6 @@ class User extends Memcached_DataObject
return $profile;
}
- function hasOpenID()
- {
- $oid = new User_openid();
-
- $oid->user_id = $this->id;
-
- $cnt = $oid->find();
-
- return ($cnt > 0);
- }
-
function getDesign()
{
return Design::staticGet('id', $this->design_id);
diff --git a/index.php b/index.php
index d8434a6cf..b9ce43c60 100644
--- a/index.php
+++ b/index.php
@@ -107,8 +107,7 @@ function checkMirror($action_obj, $args)
function isLoginAction($action)
{
- static $loginActions = array('login', 'openidlogin', 'finishopenidlogin',
- 'recoverpassword', 'api', 'doc', 'register');
+ static $loginActions = array('login', 'recoverpassword', 'api', 'doc', 'register');
$login = null;
diff --git a/lib/accountsettingsaction.php b/lib/accountsettingsaction.php
index 9814c48ab..9a7c69124 100644
--- a/lib/accountsettingsaction.php
+++ b/lib/accountsettingsaction.php
@@ -116,9 +116,6 @@ class AccountSettingsNav extends Widget
'emailsettings' =>
array(_('Email'),
_('Change email handling')),
- 'openidsettings' =>
- array(_('OpenID'),
- _('Add or remove OpenIDs')),
'userdesignsettings' =>
array(_('Design'),
_('Design your profile')),
diff --git a/lib/logingroupnav.php b/lib/logingroupnav.php
index bae45b077..59f313302 100644
--- a/lib/logingroupnav.php
+++ b/lib/logingroupnav.php
@@ -87,11 +87,6 @@ class LoginGroupNav extends Widget
$action_name === 'register');
}
- $this->action->menuItem(common_local_url('openidlogin'),
- _('OpenID'),
- _('Login or register with OpenID'),
- $action_name === 'openidlogin');
-
Event::handle('EndLoginGroupNav', array(&$this->action));
}
diff --git a/lib/router.php b/lib/router.php
index 04c6dd414..08bc0566d 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -50,8 +50,7 @@ class Router
var $m = null;
static $inst = null;
static $bare = array('requesttoken', 'accesstoken', 'userauthorization',
- 'postnotice', 'updateprofile', 'finishremotesubscribe',
- 'finishopenidlogin', 'finishaddopenid');
+ 'postnotice', 'updateprofile', 'finishremotesubscribe');
static function get()
{
@@ -76,7 +75,6 @@ class Router
$m->connect('', array('action' => 'public'));
$m->connect('rss', array('action' => 'publicrss'));
- $m->connect('xrds', array('action' => 'publicxrds'));
$m->connect('featuredrss', array('action' => 'featuredrss'));
$m->connect('favoritedrss', array('action' => 'favoritedrss'));
$m->connect('opensearch/people', array('action' => 'opensearch',
@@ -128,7 +126,6 @@ class Router
// exceptional
- $m->connect('main/openid', array('action' => 'openidlogin'));
$m->connect('main/remote', array('action' => 'remotesubscribe'));
$m->connect('main/remote?nickname=:nickname', array('action' => 'remotesubscribe'), array('nickname' => '[A-Za-z0-9_-]+'));
@@ -138,7 +135,7 @@ class Router
// settings
- foreach (array('profile', 'avatar', 'password', 'openid', 'im',
+ foreach (array('profile', 'avatar', 'password', 'im',
'email', 'sms', 'twitter', 'userdesign', 'other') as $s) {
$m->connect('settings/'.$s, array('action' => $s.'settings'));
}
@@ -453,7 +450,7 @@ class Router
// user stuff
foreach (array('subscriptions', 'subscribers',
- 'nudge', 'xrds', 'all', 'foaf',
+ 'nudge', 'all', 'foaf', 'xrds',
'replies', 'inbox', 'outbox', 'microsummary') as $a) {
$m->connect(':nickname/'.$a,
array('action' => $a),
diff --git a/lib/settingsaction.php b/lib/settingsaction.php
index 4cf9b80c4..a923a98b2 100644
--- a/lib/settingsaction.php
+++ b/lib/settingsaction.php
@@ -78,11 +78,7 @@ class SettingsAction extends CurrentUserDesignAction
common_set_returnto($this->selfUrl());
$user = common_current_user();
if (Event::handle('RedirectToLogin', array($this, $user))) {
- if ($user->hasOpenID()) {
- common_redirect(common_local_url('openidlogin'), 303);
- } else {
- common_redirect(common_local_url('login'), 303);
- }
+ common_redirect(common_local_url('login'), 303);
}
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->handlePost();
diff --git a/lib/util.php b/lib/util.php
index 3fa90d31a..b798cfe15 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -706,8 +706,7 @@ function common_local_url($action, $args=null, $params=null, $fragment=null)
function common_is_sensitive($action)
{
static $sensitive = array('login', 'register', 'passwordsettings',
- 'twittersettings', 'finishopenidlogin',
- 'finishaddopenid', 'api');
+ 'twittersettings', 'api');
$ssl = null;
if (Event::handle('SensitiveAction', array($action, &$ssl))) {
diff --git a/plugins/OpenID/OpenIDPlugin.php b/plugins/OpenID/OpenIDPlugin.php
new file mode 100644
index 000000000..87b25d42a
--- /dev/null
+++ b/plugins/OpenID/OpenIDPlugin.php
@@ -0,0 +1,199 @@
+<?php
+/**
+ * Laconica, the distributed open-source microblogging tool
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Plugin
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @copyright 2009 Control Yourself, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ */
+
+if (!defined('LACONICA')) {
+ exit(1);
+}
+
+/**
+ * Plugin for OpenID authentication and identity
+ *
+ * This class enables consumer support for OpenID, the distributed authentication
+ * and identity system.
+ *
+ * @category Plugin
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ * @link http://openid.net/
+ */
+
+class OpenIDPlugin extends Plugin
+{
+ /**
+ * Initializer for the plugin.
+ */
+
+ function __construct()
+ {
+ parent::__construct();
+ }
+
+ /**
+ * Add OpenID-related paths to the router table
+ *
+ * Hook for RouterInitialized event.
+ *
+ * @return boolean hook return
+ */
+
+ function onRouterInitialized(&$m)
+ {
+ $m->connect('main/openid', array('action' => 'openidlogin'));
+ $m->connect('settings/openid', array('action' => 'openidsettings'));
+ $m->connect('xrds', array('action' => 'publicxrds'));
+ $m->connect('index.php?action=finishopenidlogin', array('action' => 'finishopenidlogin'));
+ $m->connect('index.php?action=finishaddopenid', array('action' => 'finishaddopenid'));
+
+ return true;
+ }
+
+ function onEndLoginGroupNav(&$action)
+ {
+ $action_name = $action->trimmed('action');
+
+ $action->menuItem(common_local_url('openidlogin'),
+ _('OpenID'),
+ _('Login or register with OpenID'),
+ $action_name === 'openidlogin');
+
+ return true;
+ }
+
+ function onEndAccountSettingsNav(&$action)
+ {
+ $action_name = $action->trimmed('action');
+
+ $action->menuItem(common_local_url('openidsettings'),
+ _('OpenID'),
+ _('Add or remove OpenIDs'),
+ $action_name === 'openidsettings');
+
+ return true;
+ }
+
+ function onAutoload($cls)
+ {
+ switch ($cls)
+ {
+ case 'OpenidloginAction':
+ case 'FinishopenidloginAction':
+ case 'FinishaddopenidAction':
+ case 'XrdsAction':
+ case 'PublicxrdsAction':
+ case 'OpenidsettingsAction':
+ require_once(INSTALLDIR.'/plugins/OpenID/' . strtolower(mb_substr($cls, 0, -6)) . '.php');
+ return false;
+ case 'User_openid':
+ require_once(INSTALLDIR.'/plugins/OpenID/User_openid.php');
+ return false;
+ default:
+ return true;
+ }
+ }
+
+ function onSensitiveAction($action, &$ssl)
+ {
+ switch ($action)
+ {
+ case 'finishopenidlogin':
+ case 'finishaddopenid':
+ $ssl = true;
+ return false;
+ default:
+ return true;
+ }
+ }
+
+ function onLoginAction($action, &$login)
+ {
+ switch ($action)
+ {
+ case 'openidlogin':
+ case 'finishopenidlogin':
+ $login = true;
+ return false;
+ default:
+ return true;
+ }
+ }
+
+ /**
+ * We include a <meta> element linking to the publicxrds page, for OpenID
+ * client-side authentication.
+ *
+ * @return void
+ */
+
+ function onEndHeadChildren($action)
+ {
+ // for client side of OpenID authentication
+ $action->element('meta', array('http-equiv' => 'X-XRDS-Location',
+ 'content' => common_local_url('publicxrds')));
+ }
+
+ /**
+ * Redirect to OpenID login if they have an OpenID
+ *
+ * @return boolean whether to continue
+ */
+
+ function onRedirectToLogin($action, $user)
+ {
+ if (!empty($user) && User_openid::hasOpenID($user->id)) {
+ common_redirect(common_local_url('openidlogin'), 303);
+ return false;
+ }
+ return true;
+ }
+
+ function onEndShowPageNotice($action)
+ {
+ $name = $action->trimmed('action');
+
+ switch ($name)
+ {
+ case 'register':
+ $instr = '(Have an [OpenID](http://openid.net/)? ' .
+ 'Try our [OpenID registration]'.
+ '(%%action.openidlogin%%)!)';
+ break;
+ case 'login':
+ $instr = '(Have an [OpenID](http://openid.net/)? ' .
+ 'Try our [OpenID login]'.
+ '(%%action.openidlogin%%)!)';
+ break;
+ default:
+ return true;
+ }
+
+ $output = common_markup_to_html($instr);
+ $action->raw($output);
+ return true;
+ }
+}
diff --git a/classes/User_openid.php b/plugins/OpenID/User_openid.php
index f4fda1c72..338e0f6e9 100644
--- a/classes/User_openid.php
+++ b/plugins/OpenID/User_openid.php
@@ -4,7 +4,7 @@
*/
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
-class User_openid extends Memcached_DataObject
+class User_openid extends Memcached_DataObject
{
###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */
@@ -22,4 +22,15 @@ class User_openid extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
+
+ static function hasOpenID($user_id)
+ {
+ $oid = new User_openid();
+
+ $oid->user_id = $user_id;
+
+ $cnt = $oid->find();
+
+ return ($cnt > 0);
+ }
}
diff --git a/actions/finishaddopenid.php b/plugins/OpenID/finishaddopenid.php
index 32bceecfd..7753158d5 100644
--- a/actions/finishaddopenid.php
+++ b/plugins/OpenID/finishaddopenid.php
@@ -31,7 +31,7 @@ if (!defined('LACONICA')) {
exit(1);
}
-require_once INSTALLDIR.'/lib/openid.php';
+require_once INSTALLDIR.'/plugins/OpenID/openid.php';
/**
* Complete adding an OpenID
diff --git a/actions/finishopenidlogin.php b/plugins/OpenID/finishopenidlogin.php
index a29195826..87fc3881e 100644
--- a/actions/finishopenidlogin.php
+++ b/plugins/OpenID/finishopenidlogin.php
@@ -19,7 +19,7 @@
if (!defined('LACONICA')) { exit(1); }
-require_once(INSTALLDIR.'/lib/openid.php');
+require_once INSTALLDIR.'/plugins/OpenID/openid.php';
class FinishopenidloginAction extends Action
{
diff --git a/lib/openid.php b/plugins/OpenID/openid.php
index 0b7633284..4787cd605 100644
--- a/lib/openid.php
+++ b/plugins/OpenID/openid.php
@@ -19,7 +19,7 @@
if (!defined('LACONICA')) { exit(1); }
-require_once(INSTALLDIR.'/classes/User_openid.php');
+require_once(INSTALLDIR.'/plugins/OpenID/User_openid.php');
require_once('Auth/OpenID.php');
require_once('Auth/OpenID/Consumer.php');
diff --git a/actions/openidlogin.php b/plugins/OpenID/openidlogin.php
index 744aae713..76f573b9f 100644
--- a/actions/openidlogin.php
+++ b/plugins/OpenID/openidlogin.php
@@ -19,7 +19,7 @@
if (!defined('LACONICA')) { exit(1); }
-require_once(INSTALLDIR.'/lib/openid.php');
+require_once INSTALLDIR.'/plugins/OpenID/openid.php';
class OpenidloginAction extends Action
{
diff --git a/actions/openidsettings.php b/plugins/OpenID/openidsettings.php
index 40a480dc4..57389903d 100644
--- a/actions/openidsettings.php
+++ b/plugins/OpenID/openidsettings.php
@@ -32,7 +32,7 @@ if (!defined('LACONICA')) {
}
require_once INSTALLDIR.'/lib/accountsettingsaction.php';
-require_once INSTALLDIR.'/lib/openid.php';
+require_once INSTALLDIR.'/plugins/OpenID/openid.php';
/**
* Settings for OpenID
diff --git a/actions/publicxrds.php b/plugins/OpenID/publicxrds.php
index 0a1421550..f088c25d1 100644
--- a/actions/publicxrds.php
+++ b/plugins/OpenID/publicxrds.php
@@ -33,7 +33,7 @@ if (!defined('LACONICA')) {
exit(1);
}
-require_once INSTALLDIR.'/lib/openid.php';
+require_once INSTALLDIR.'/plugins/OpenID/openid.php';
/**
* Public XRDS for OpenID