hint about openid timeouts
[indieauth-openid.git] / www / index.php
index 496d7d3bbede3e1bd271971a036ce511e03ca419..2e6b4c8c4bb0671977816a67320e415994146020 100644 (file)
  * @link    http://indiewebcamp.com/auth-brainstorming
  * @link    https://indieauth.com/developers
  */
+header('IndieAuth: authorization_endpoint');
+if (($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD')
+    && count($_GET) == 0
+) {
+    include 'about.php';
+    exit();
+}
 
 require_once 'Net/URL2.php';
+require_once 'OpenID.php';
 require_once 'OpenID/RelyingParty.php';
 require_once 'OpenID/Message.php';
 require_once 'OpenID/Exception.php';
@@ -124,7 +132,6 @@ function getBaseUrl()
         . $file;
 }
 
-header('IndieAuth: authorization_endpoint');
 session_start();
 $returnTo = getBaseUrl();
 $realm    = getBaseUrl();
@@ -139,7 +146,7 @@ if (isset($_GET['openid_mode']) && $_GET['openid_mode'] != '') {
 
     $message = new \OpenID_Message($queryString, \OpenID_Message::FORMAT_HTTP);
     $id      = $message->get('openid.claimed_id');
-    if ($id != $_SESSION['me']) {
+    if (OpenID::normalizeIdentifier($id) != OpenID::normalizeIdentifier($_SESSION['me'])) {
         error(
             sprintf(
                 'Given identity URL "%s" and claimed OpenID "%s" do not match',
@@ -194,6 +201,11 @@ if ($_SERVER['REQUEST_METHOD'] == 'GET') {
 
     try {
         $o = new \OpenID_RelyingParty($returnTo, $realm, $me);
+        //if you get timeouts (errors like
+        // OpenID error: Request timed out after 3 second(s)
+        //) then uncomment the following line which disables
+        // all timeouts:
+        //$o->setRequestOptions(array('follow_redirects' => true));
         $authRequest = $o->prepare();
         $url = $authRequest->getAuthorizeURL();
         header("Location: $url");