# There is no obvious way to automatically use the latest version
get-openid:
- @if ! test -d include/openid; then \
+ @if ! test -d include/Auth; then \
wget http://openidenabled.com/files/php-openid/packages/php-openid-2.1.2.tar.bz2; \
tar -xjf php-openid-2.1.2.tar.bz2; \
- mv php-openid-2.1.2/Auth include/openid; \
+ mv php-openid-2.1.2/Auth include/; \
rm php-openid-2.1.2.tar.bz2; \
rm -r php-openid-2.1.2; \
fi
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-
-
class OpenidModule extends PLModule
{
function handlers()
{
return array(
'openid' => $this->make_hook('openid', AUTH_PUBLIC),
+ 'openid/idp_xrds' => $this->make_hook('idp_xrds', AUTH_PUBLIC),
+ 'openid/user_xrds' => $this->make_hook('user_xrds', AUTH_PUBLIC),
+ 'openid/trust' => $this->make_hook('trust', AUTH_PUBLIC),
);
}
+ function init_openid()
+ {
+ require_once 'Auth/OpenID.php';
+ $this->load('openid.inc.php');
+ }
+
function handler_openid(&$page, $x = null)
{
+ global $globals;
+
// Determines the user whose openid we are going to display
if (is_null($x)) {
return PL_NOT_FOUND;
return PL_NOT_FOUND;
}
+ // Include X-XRDS-Location response-header for Yadis discovery
+ $user_xrds = $globals->baseurl . 'openid/user_xrds/' . $login->hruid;
+ header('X-XRDS-Location: ' . $user_xrds);
+
// Select template
$page->changeTpl('openid/openid.tpl');
// Adds the global user property array to the display.
$page->assign_by_ref('user', $login);
+ }
+
+ function handler_idp_xrds(&$page)
+ {
+ global $globals;
+
+ // Load constants
+ require_once "Auth/OpenID/Discover.php";
+
+ // Set XRDS content-type and template
+ header('Content-type: application/xrds+xml');
+ $page->changeTpl('openid/idp_xrds.tpl', NO_SKIN);
+
+ // Set variables
+ $page->changeTpl('openid/idp_xrds.tpl', NO_SKIN);
+ $page->assign('type', Auth_OpenID_TYPE_2_0_IDP);
+ $page->assign('uri', $globals->baseurl . '/openid');
+ }
+
+ function handler_user_xrds(&$page, $x = null)
+ {
+ global $globals;
+
+ // Load constants
+ require_once "Auth/OpenID/Discover.php";
+ // 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', $globals->baseurl . '/openid');
}
}