Use hruid as openid identifier
authorAymeric Augustin <aymeric.augustin@m4x.org>
Wed, 29 Oct 2008 21:01:29 +0000 (22:01 +0100)
committerAymeric Augustin <aymeric.augustin@m4x.org>
Wed, 29 Oct 2008 21:13:59 +0000 (22:13 +0100)
modules/openid.php
templates/openid/user_xrds.tpl

index bd74eee..067e0a0 100644 (file)
@@ -77,7 +77,7 @@ class OpenidModule extends PLModule
             // Each user has only one identity to choose from
             // So we can make automatically the identity selection
             if ($request->idSelect()) {
-                $request->identity = get_user_openid_url($user);
+                $request->identity = $user->hruid();
             }
 
             // If we still don't have an identifier (used or desired), give up
@@ -127,7 +127,7 @@ class OpenidModule extends PLModule
         $user = S::user();
 
         // Check that the identity matches the user currently logged in
-        if ($request->identity != get_user_openid_url($user)) {
+        if ($request->identity != $user->hruid) {
             $response =& $request->answer(false);
             $webresponse =& $server->encodeResponse($response);
             $this->render_openid_response($webresponse);
@@ -173,14 +173,21 @@ class OpenidModule extends PLModule
         // Load constants
         $this->load('openid.inc.php');
 
+        // Make sure the user exists
+        $user = get_user($x);
+        if (is_null($user)) {
+            return PL_NOT_FOUND;
+        }
+
         // Set XRDS content-type and template
         header('Content-type: application/xrds+xml');
         $page->changeTpl('openid/user_xrds.tpl', NO_SKIN);
 
         // Set variables
-        $page->assign('type1', Auth_OpenID_TYPE_2_0);
-        $page->assign('type2', Auth_OpenID_TYPE_1_1);
-        $page->assign('uri', get_openid_url());
+        $page->assign('type2', Auth_OpenID_TYPE_2_0);
+        $page->assign('type1', Auth_OpenID_TYPE_1_1);
+        $page->assign('provider', get_openid_url());
+        $page->assign('local_id', $user->hruid);
     }
 
     function handler_melix(&$page, $x = null)
index 44c03a9..eff0fc4 100644 (file)
@@ -1,12 +1,18 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <xrds:XRDS
     xmlns:xrds="xri://$xrds"
-    xmlns="xri://$xrd*($v*2.0)">
+    xmlns="xri://$xrd*($v*2.0)"
+    xmlns:openid="http://openid.net/xmlns/1.0">
   <XRD>
-    <Service priority="0">
+    <Service priority="10">
       <Type>{$type2}</Type>
+      <URI>{$provider}</URI>
+      <LocalID>{$local_id}</LocalID>
+    </Service>
+    <Service priority="20">
       <Type>{$type1}</Type>
-      <URI>{$uri}</URI>
+      <URI>{$provider}</URI>
+      <openid:Delegate>{$local_id}</openid:Delegate>
     </Service>
   </XRD>
-</xrds:XRDS>
\ No newline at end of file
+</xrds:XRDS>