]> git.mxchange.org Git - friendica.git/commitdiff
Issue 6168: "redir" now mostly use OWA
authorMichael <heluecht@pirati.ca>
Tue, 4 Dec 2018 07:12:55 +0000 (07:12 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 4 Dec 2018 07:12:55 +0000 (07:12 +0000)
mod/dfrn_poll.php
mod/redir.php
src/Model/Contact.php
src/Network/CurlResult.php
src/Network/Probe.php
src/Util/LDSignature.php

index 646047ea551d08578fbded0834ef030bc0e7c5ff..001202d5e564e639d9f464d9ac4937db230a2112 100644 (file)
@@ -561,11 +561,7 @@ function dfrn_poll_content(App $a)
                                        break;
                                default:
                                        $appendix = (strstr($destination_url, '?') ? '&f=&redir=1' : '?f=&redir=1');
-                                       if (filter_var($url, FILTER_VALIDATE_URL)) {
-                                               System::externalRedirect($destination_url . $appendix);
-                                       } else {
-                                               $a->internalRedirect($destination_url . $appendix);
-                                       }
+                                       $a->redirect($destination_url . $appendix);
                                        break;
                        }
                        // NOTREACHED
index 9f579a9dc445f3657fb2a3b6e2b249713d2174f3..f8dfa3ab9fe8e115191b42d29758c8ce87b06da2 100644 (file)
@@ -9,6 +9,7 @@ use Friendica\Database\DBA;
 use Friendica\Model\Contact;
 use Friendica\Model\Profile;
 use Friendica\Util\Strings;
+use Friendica\Util\Network;
 
 function redir_init(App $a) {
 
@@ -34,8 +35,7 @@ function redir_init(App $a) {
 
                $contact_url = $contact['url'];
 
-               if ($contact['network'] !== Protocol::DFRN // Authentication isn't supported for non DFRN contacts.
-                       || (!local_user() && !remote_user()) // Visitors (not logged in or not remotes) can't authenticate.
+               if ((!local_user() && !remote_user()) // Visitors (not logged in or not remotes) can't authenticate.
                        || (!empty($a->contact['id']) && $a->contact['id'] == $cid)) // Local user is already authenticated.
                {
                        $a->redirect(defaults($url, $contact_url));
@@ -81,6 +81,14 @@ function redir_init(App $a) {
                        }
                }
 
+               // When the remote page does support OWA, then we enforce the use of it
+               $basepath = Contact::getBasepath($contact_url);
+               $serverret = Network::curl($basepath . '/magic');
+               if ($serverret->isSuccess()) {
+                       $contact['issued-id'] = '';
+                       $contact['dfrn-id'] = '';
+               }
+
                // Doing remote auth with dfrn.
                if (local_user() && (!empty($contact['dfrn-id']) || !empty($contact['issued-id'])) && empty($contact['pending'])) {
                        $dfrn_id = $orig_id = (($contact['issued-id']) ? $contact['issued-id'] : $contact['dfrn-id']);
index 5392462854f804efc95eb8c404d9d0ce1983e4c3..5507ba3d1d7bde5e02424cc22d879bbdcdc0b3ea 100644 (file)
@@ -98,6 +98,26 @@ class Contact extends BaseObject
         * @}
         */
 
+       /**
+        * @brief Get the basepath for a given contact link
+        *
+        * @param string $url The contact link
+        *
+        * @return string basepath
+        */
+       public static function getBasepath($url)
+       {
+               $data = Probe::uri($url);
+               if (!empty($data['baseurl'])) {
+                       return $data['baseurl'];
+               }
+
+               $urlarr = explode('/profile/', $url);
+                $basepath = $urlarr[0];
+
+               return $basepath;
+       }
+
        /**
         * @brief Returns the contact id for the user and the public contact id for a given contact id
         *
index b2587799d19bdc9b9bc9ac495cbf428a777b9cec..eb446af4e75336ec6608a69883544cfe782b6884 100644 (file)
@@ -177,7 +177,7 @@ class CurlResult
 
                        $this->redirectUrl = Network::unparseURL($redirect_parts);
 
-                       $this->isRedirectUrl = filter_var($this->redirectUrl, FILTER_VALIDATE_URL) !== false;
+                       $this->isRedirectUrl = true;
                } else {
                        $this->isRedirectUrl = false;
                }
index 5d392a2af88b93ef8db25bdf526788d2c949546a..f4e3d1d43c55d433f875b840a781dac3171bceb4 100644 (file)
@@ -164,7 +164,7 @@ class Probe
                        }
                }
 
-               self::$baseurl = "http://".$host;
+               self::$baseurl = $host_url;
 
                Logger::log("Probing successful for ".$host, Logger::DEBUG);
 
index c9fde441fdcfcbcb4e80bdafff36b02cd163cca3..5acdfd9013aeae4a981af022bc74896bd39c9363 100644 (file)
@@ -27,7 +27,7 @@ class LDSignature
                }
 
                $actor = JsonLD::fetchElement($data, 'actor', 'id');
-               if (empty($actor)) {
+               if (empty($actor) || !is_string($actor)) {
                        return false;
                }