From 6d64882270aa3dda3cb184d848692123e552ef1e Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 4 Aug 2009 06:43:26 -0400 Subject: [PATCH] OpenIDPlugin sets up actions for router --- lib/router.php | 9 ++-- plugins/OpenID/OpenIDPlugin.php | 78 +++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 plugins/OpenID/OpenIDPlugin.php diff --git a/lib/router.php b/lib/router.php index 19839b9972..37a7e4a0f3 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', @@ -131,7 +129,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_-]+')); @@ -141,7 +138,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')); } @@ -434,7 +431,7 @@ class Router // user stuff foreach (array('subscriptions', 'subscribers', - 'nudge', 'xrds', 'all', 'foaf', + 'nudge', 'all', 'foaf', 'replies', 'inbox', 'outbox', 'microsummary') as $a) { $m->connect(':nickname/'.$a, array('action' => $a), diff --git a/plugins/OpenID/OpenIDPlugin.php b/plugins/OpenID/OpenIDPlugin.php new file mode 100644 index 0000000000..149a92356d --- /dev/null +++ b/plugins/OpenID/OpenIDPlugin.php @@ -0,0 +1,78 @@ +. + * + * @category Plugin + * @package Laconica + * @author Evan Prodromou + * @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 + * @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(':nickname/xrds', + array('action' => 'xrds'), + array('nickname' => '[a-zA-Z0-9]{1,64}')); + $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; + } +} \ No newline at end of file