Revision: 2169
Author: olavmrk
Date: Wed Feb 10 05:04:00 2010
Log: openidProvider: Add XRDS support.
http://code.google.com/p/simplesamlphp/source/detail?r=2169

Added:
 /trunk/modules/openidProvider/www/xrds.php
Modified:
 /trunk/modules/openidProvider/templates/user.tpl.php
 /trunk/modules/openidProvider/www/user.php

=======================================
--- /dev/null
+++ /trunk/modules/openidProvider/www/xrds.php  Wed Feb 10 05:04:00 2010
@@ -0,0 +1,48 @@
+<?php
+
+/**
+ * This endpoint returns an XRDS document describing this server.
+ *
+ * @package simpleSAMLphp
+ * @version $Id$
+ */
+
+if (isset($_REQUEST['user'])) {
+       $user = (string)$_REQUEST['user'];
+       $serviceTypes = array(
+               'http://specs.openid.net/auth/2.0/signon',
+               'http://openid.net/server/1.0',
+               'http://openid.net/server/1.1',
+       );
+} else {
+       $user = NULL;
+       $serviceTypes = array(
+               'http://specs.openid.net/auth/2.0/server',
+       );
+}
+
+$server = sspmod_openidProvider_Server::getInstance();
+
+$serverURL = $server->getServerURL();
+
+header('Content-Type: application/xrds+xml');
+
+echo('<?xml version="1.0" encoding="UTF-8"?>' . "\n");
+echo('<xrds:XRDS xmlns:xrds="xri://$xrds" xmlns="xri://$xrd*($v*2.0)">');
+echo('<XRD>');
+echo('<Service priority="0">');
+
+foreach ($serviceTypes as $t) {
+       echo('<Type>' . htmlspecialchars($t) . '</Type>');
+}
+
+echo('<URI>' . htmlspecialchars($serverURL) . '</URI>');
+
+if ($user !== NULL) {
+ $localId = SimpleSAML_Module::getModuleURL('openidProvider/user.php') . '/' . $user;
+       echo('<LocalID>' . htmlspecialchars($localId) . '</LocalID>');
+}
+
+echo('</Service>');
+echo('</XRD>');
+echo('</xrds:XRDS>');
=======================================
--- /trunk/modules/openidProvider/templates/user.tpl.php Wed Feb 10 05:03:50 2010 +++ /trunk/modules/openidProvider/templates/user.tpl.php Wed Feb 10 05:04:00 2010
@@ -8,6 +8,9 @@
 $trustedSites = $this->data['trustedSites'];
 $userId = $this->data['userId'];
 $userIdURL = $this->data['userIdURL'];
+$xrdsURL = $this->data['xrdsURL'];
+
+header('X-XRDS-Location: ' . $xrdsURL);

 if ($userId !== FALSE) {
$title = $this->t('{openidProvider:openidProvider:title_user}', array('%USERID%' => htmlspecialchars($userId)));
=======================================
--- /trunk/modules/openidProvider/www/user.php  Fri Oct 16 04:05:04 2009
+++ /trunk/modules/openidProvider/www/user.php  Wed Feb 10 05:04:00 2010
@@ -49,6 +49,11 @@
 }

 $userBase = SimpleSAML_Module::getModuleURL('openidProvider/user.php');
+
+$xrds = SimpleSAML_Module::getModuleURL('openidProvider/xrds.php');
+if ($userId !== FALSE) {
+ $xrds = SimpleSAML_Utilities::addURLparameter($xrds, array('user' => $userId));
+}

 $as = $server->getAuthSource();
$t = new SimpleSAML_XHTML_Template($globalConfig, 'openidProvider:user.tpl.php');
@@ -61,5 +66,7 @@
 $t->data['trustedSites'] = $trustedSites;
 $t->data['userId'] = $userId;
 $t->data['userIdURL'] = $userBase . '/' . $userId;
+$t->data['xrdsURL'] = $xrds;
+
 $t->show();
 exit(0);

--
You received this message because you are subscribed to the Google Groups 
"simpleSAMLphp commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/simplesamlphp-commits?hl=en.

Reply via email to