]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OpenID/OpenIDPlugin.php
Merged
[quix0rs-gnu-social.git] / plugins / OpenID / OpenIDPlugin.php
index e48b616f4d180d5e2c1475cc437abb27652c9ae2..95ca5730eb65343b1c28b22ee90488aa266be343 100644 (file)
@@ -68,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'));
@@ -125,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.'));
@@ -156,7 +154,7 @@ class OpenIDPlugin extends Plugin
      *
      * @return boolean hook return
      */
-    function onEndPublicXRDS($action, &$xrdsOutputter)
+    function onEndPublicXRDS(Action $action, &$xrdsOutputter)
     {
         $xrdsOutputter->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
                                                   'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
@@ -176,37 +174,6 @@ class OpenIDPlugin extends Plugin
         $xrdsOutputter->elementEnd('XRD');
     }
 
-    /**
-     * User XRDS output hook
-     *
-     * Puts the bits of code needed to discover OpenID endpoints.
-     *
-     * @param Action       $action         Action being executed
-     * @param XMLOutputter &$xrdsOutputter Output channel
-     *
-     * @return boolean hook return
-     */
-    function onEndUserXRDS($action, &$xrdsOutputter)
-    {
-        $xrdsOutputter->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
-                                                  'xml:id' => 'openid',
-                                                  'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
-                                                  'version' => '2.0'));
-        $xrdsOutputter->element('Type', null, 'xri://$xrds*simple');
-
-        //consumer
-        $xrdsOutputter->showXrdsService('http://specs.openid.net/auth/2.0/return_to',
-                                        common_local_url('finishopenidlogin'));
-
-        //provider
-        $xrdsOutputter->showXrdsService('http://specs.openid.net/auth/2.0/signon',
-                                        common_local_url('openidserver'),
-                                        null,
-                                        null,
-                                        common_profile_url($action->user->nickname));
-        $xrdsOutputter->elementEnd('XRD');
-    }
-
     /**
      * If we're in OpenID-only mode, hide all the main menu except OpenID login.
      *
@@ -275,7 +242,7 @@ class OpenIDPlugin extends Plugin
      *
      * @return boolean hook return
      */
-    function onEndLoginGroupNav($action)
+    function onEndLoginGroupNav(Action $action)
     {
         $this->showOpenIDLoginTab($action);
 
@@ -417,17 +384,22 @@ class OpenIDPlugin extends Plugin
      *
      * @return void
      */
-    function onEndShowHeadElements($action)
+    function onEndShowHeadElements(Action $action)
     {
         if ($action instanceof ShowstreamAction) {
             $action->element('link', array('rel' => 'openid2.provider',
                                            'href' => common_local_url('openidserver')));
             $action->element('link', array('rel' => 'openid2.local_id',
-                                           'href' => $action->profile->profileurl));
+                                           'href' => $action->getTarget()->getUrl()));
             $action->element('link', array('rel' => 'openid.server',
                                            'href' => common_local_url('openidserver')));
             $action->element('link', array('rel' => 'openid.delegate',
-                                           'href' => $action->profile->profileurl));
+                                           'href' => $action->getTarget()->getUrl()));
+        }
+
+        if ($action instanceof SitestreamAction) {
+            $action->element('meta', array('http-equiv' => 'X-XRDS-Location',
+                                         'content' => common_local_url('publicxrds')));
         }
         return true;
     }
@@ -442,9 +414,8 @@ class OpenIDPlugin extends Plugin
      */
     function onRedirectToLogin($action, $user)
     {
-        if (common_config('site', 'openid_only') || (!empty($user) && User_openid::hasOpenID($user->id))) {
+        if (common_config('site', 'openidonly') || (!empty($user) && User_openid::hasOpenID($user->id))) {
             common_redirect(common_local_url('openidlogin'), 303);
-            return false;
         }
         return true;
     }
@@ -456,7 +427,7 @@ class OpenIDPlugin extends Plugin
      *
      * @return boolean hook value
      */
-    function onEndShowPageNotice($action)
+    function onEndShowPageNotice(Action $action)
     {
         $name = $action->trimmed('action');
 
@@ -550,13 +521,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(
@@ -566,7 +537,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'),
                                  ),
                              ));
 
@@ -595,7 +566,7 @@ class OpenIDPlugin extends Plugin
      *
      * @return boolean hook value
      */
-    function onEndAdminPanelNav($nav)
+    function onEndAdminPanelNav(Menu $nav)
     {
         if (AdminPanelAction::canAdmin('openid')) {
 
@@ -644,10 +615,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' =>
@@ -773,7 +744,7 @@ class OpenIDPlugin extends Plugin
      * @return boolean hook value (always true)
      */
 
-    function onEndXrdActionLinks(XML_XRD $xrd, Profile $target)
+    function onEndWebFingerProfileLinks(XML_XRD $xrd, Profile $target)
     {
         $xrd->links[] = new XML_XRD_Element_Link(
                             'http://specs.openid.net/auth/2.0/provider',