]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OpenID/OpenIDPlugin.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / plugins / OpenID / OpenIDPlugin.php
index f4a9e061a1be6a2ff7fb0697240eefbfe9d41627..d8a77ca41dc3623f614908cdce9ab3de86c25740 100644 (file)
@@ -37,6 +37,8 @@ if (!defined('STATUSNET')) {
  * This class enables consumer support for OpenID, the distributed authentication
  * and identity system.
  *
+ * Depends on: WebFinger plugin for HostMeta-lookup (user@host format)
+ *
  * @category Plugin
  * @package  StatusNet
  * @author   Evan Prodromou <evan@status.net>
@@ -66,11 +68,11 @@ class OpenIDPlugin extends Plugin
      *
      * Hook for RouterInitialized event.
      *
-     * @param Net_URL_Mapper $m URL mapper
+     * @param URLMapper $m URL mapper
      *
      * @return boolean hook return
      */
-    function onStartInitializeRouter($m)
+    public function onStartInitializeRouter(URLMapper $m)
     {
         $m->connect('main/openid', array('action' => 'openidlogin'));
         $m->connect('main/openidtrust', array('action' => 'openidtrust'));
@@ -123,17 +125,15 @@ class OpenIDPlugin extends Plugin
      *
      * @return boolean hook return
      */
-    function onArgsInitialize($args)
+    function onArgsInitialize(array &$args)
     {
         if (common_config('site', 'openidonly')) {
             if (array_key_exists('action', $args)) {
                 $action = trim($args['action']);
                 if (in_array($action, array('login', 'register'))) {
                     common_redirect(common_local_url('openidlogin'));
-                    exit(0);
                 } else if ($action == 'passwordsettings') {
                     common_redirect(common_local_url('openidsettings'));
-                    exit(0);
                 } else if ($action == 'recoverpassword') {
                     // TRANS: Client exception thrown when an action is not available.
                     throw new ClientException(_m('Unavailable action.'));
@@ -408,8 +408,8 @@ class OpenIDPlugin extends Plugin
     }
 
     /**
-     * We include a <meta> element linking to the userxrds page, for OpenID
-     * client-side authentication.
+     * We include a <meta> element linking to the webfinger resource page,
+     * for OpenID client-side authentication.
      *
      * @param Action $action Action being shown
      *
@@ -442,7 +442,6 @@ class OpenIDPlugin extends Plugin
     {
         if (common_config('site', 'openid_only') || (!empty($user) && User_openid::hasOpenID($user->id))) {
             common_redirect(common_local_url('openidlogin'), 303);
-            return false;
         }
         return true;
     }
@@ -548,13 +547,13 @@ class OpenIDPlugin extends Plugin
                              array(
                                  'fields' => array(
                                      'server_url' => array('type' => 'blob', 'not null' => true),
-                                     'handle' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'default' => ''), // character set latin1,
+                                     'handle' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'default' => ''), // character set latin1,
                                      'secret' => array('type' => 'blob'),
                                      'issued' => array('type' => 'int'),
                                      'lifetime' => array('type' => 'int'),
                                      'assoc_type' => array('type' => 'varchar', 'length' => 64),
                                  ),
-                                 'primary key' => array(array('server_url', 255), 'handle'),
+                                 'primary key' => array(array('server_url', 191), 'handle'),
                              ));
         $schema->ensureTable('oid_nonces',
                              array(
@@ -564,7 +563,7 @@ class OpenIDPlugin extends Plugin
                                      'salt' => array('type' => 'char', 'length' => 40),
                                  ),
                                  'unique keys' => array(
-                                     'oid_nonces_server_url_timestamp_salt_key' => array(array('server_url', 255), 'timestamp', 'salt'),
+                                     'oid_nonces_server_url_timestamp_salt_key' => array(array('server_url', 191), 'timestamp', 'salt'),
                                  ),
                              ));
 
@@ -593,7 +592,7 @@ class OpenIDPlugin extends Plugin
      *
      * @return boolean hook value
      */
-    function onEndAdminPanelNav($nav)
+    function onEndAdminPanelNav(Menu $nav)
     {
         if (AdminPanelAction::canAdmin('openid')) {
 
@@ -642,10 +641,10 @@ class OpenIDPlugin extends Plugin
      *
      * @return boolean hook value
      */
-    function onPluginVersion(&$versions)
+    function onPluginVersion(array &$versions)
     {
         $versions[] = array('name' => 'OpenID',
-                            'version' => STATUSNET_VERSION,
+                            'version' => GNUSOCIAL_VERSION,
                             'author' => 'Evan Prodromou, Craig Andrews',
                             'homepage' => 'http://status.net/wiki/Plugin:OpenID',
                             'rawdescription' =>
@@ -736,7 +735,7 @@ class OpenIDPlugin extends Plugin
             oid_assert_allowed($openid_url);
 
             $returnto = common_local_url(
-                'ApiOauthAuthorize',
+                'ApiOAuthAuthorize',
                 array(),
                 array(
                     'oauth_token' => $action->arg('oauth_token'),
@@ -765,20 +764,17 @@ class OpenIDPlugin extends Plugin
      * Webfinger identity to services that support it. See
      * http://webfinger.org/login for an example.
      *
-     * @param XRD  &$xrd Currently-displaying XRD object
-     * @param User $user The user that it's for
+     * @param XML_XRD   $xrd    Currently-displaying resource descriptor
+     * @param Profile   $target The profile that it's for
      *
      * @return boolean hook value (always true)
      */
 
-    function onEndXrdActionLinks(&$xrd, $user)
+    function onEndWebFingerProfileLinks(XML_XRD $xrd, Profile $target)
     {
-        $profile = $user->getProfile();
-
-        if (!empty($profile)) {
-            $xrd->links[] = array('rel' => 'http://specs.openid.net/auth/2.0/provider',
-                                  'href' => $profile->profileurl);
-        }
+        $xrd->links[] = new XML_XRD_Element_Link(
+                            'http://specs.openid.net/auth/2.0/provider',
+                            $target->profileurl);
 
         return true;
     }