Re-add a proper identification provider XRDS
authorAymeric Augustin <aymeric.augustin@m4x.org>
Thu, 30 Oct 2008 22:14:45 +0000 (23:14 +0100)
committerAymeric Augustin <aymeric.augustin@m4x.org>
Thu, 30 Oct 2008 22:14:45 +0000 (23:14 +0100)
We're going to enable users to enter an OP identifier and not a claimed identifier

modules/openid.php
modules/openid/openid.inc.php
modules/platal.php
templates/openid/idp_xrds.tpl [new file with mode: 0644]

index 66ad7e2..8e65c07 100644 (file)
@@ -49,6 +49,7 @@ class OpenidModule extends PLModule
         return array(
             'openid'            => $this->make_hook('openid', AUTH_PUBLIC),
             'openid/trust'      => $this->make_hook('trust', AUTH_COOKIE),
+            'openid/idp_xrds'   => $this->make_hook('idp_xrds', AUTH_PUBLIC),
             'openid/user_xrds'  => $this->make_hook('user_xrds', AUTH_PUBLIC),
             'openid/melix'      => $this->make_hook('melix', AUTH_PUBLIC),
         );
@@ -168,6 +169,21 @@ class OpenidModule extends PLModule
         $this->render_openid_response($webresponse);
     }
 
+    function handler_idp_xrds(&$page)
+    {
+        // Load constants
+        $this->load('openid.inc.php');
+
+        // Set XRDS content-type and template
+        header('Content-type: application/xrds+xml');
+        $page->changeTpl('openid/idp_xrds.tpl', NO_SKIN);
+
+        // Set variables
+        $page->assign('type2', Auth_OpenID_TYPE_2_0_IDP);
+        $page->assign('sreg', Auth_OpenID_SREG_URI);
+        $page->assign('provider', get_openid_url());
+    }
+
     function handler_user_xrds(&$page, $x = null)
     {
         // Load constants
index e4a7b12..a31263d 100644 (file)
@@ -78,6 +78,12 @@ function get_user_openid_url($user)
     return $globals->baseurl . '/openid/' . $user->hruid;
 }
 
+function get_idp_xrds_url()
+{
+    global $globals;
+    return $globals->baseurl . '/openid/idp_xrds';
+}
+
 function get_user_xrds_url($user)
 {
     if (is_null($user)) {
index 951803b..9908013 100644 (file)
@@ -62,6 +62,12 @@ class PlatalModule extends PLModule
 
     function handler_index(&$page)
     {
+        global $globals;
+
+        // Include X-XRDS-Location response-header for Yadis discovery
+        header('X-XRDS-Location: ' . $globals->baseurl . '/openid/idp_xrds');
+
+        // Redirect to the suitable page
         if (S::logged()) {
             pl_redirect('events');
         } else if (!@$GLOBALS['IS_XNET_SITE']) {
diff --git a/templates/openid/idp_xrds.tpl b/templates/openid/idp_xrds.tpl
new file mode 100644 (file)
index 0000000..6e273c5
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xrds:XRDS
+    xmlns:xrds="xri://$xrds"
+    xmlns="xri://$xrd*($v*2.0)"
+    xmlns:openid="http://openid.net/xmlns/1.0">
+  <XRD>
+    <Service>
+      <Type>{$type2}</Type>
+      <Type>{$sreg}</Type>
+      <URI>{$provider}</URI>
+    </Service>
+  </XRD>
+</xrds:XRDS>