Skip to content

Commit 28b684f

Browse files
author
tailor
committed
[project @ Add examples/discover.php tool]
1 parent aa82a2a commit 28b684f

File tree

3 files changed

+103
-0
lines changed

3 files changed

+103
-0
lines changed

CHANGES-2.1.0

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* Server API: Auth_OpenID_OpenIDResponse::toHTML
1616

1717
* New Features
18+
* Added examples/discover.php, an OpenID service discovery tool
1819
* Add optional form_tag_attrs argument to
1920
Auth_OpenID_ServerResponse::toFormMarkup for setting arbitrary
2021
FORM element attributes

README

+5
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ examples/README file for more details.
6565
TROUBLESHOOTING
6666
===============
6767

68+
* If you're unable to use an OpenID URL with the library, you may want
69+
to try using the discover tool (examples/discover.php). This tool
70+
will perform OpenID discovery on the identifier and give a list of
71+
discovered OpenID services and their types.
72+
6873
* On some systems, PHP basedir restrictions prevent web servers from
6974
opening a source of randomness, such as /dev/urandom. If your PHP
7075
OpenID library has trouble getting a satisfactory source of

examples/discover.php

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?php
2+
require_once "Auth/OpenID/Discover.php";
3+
require_once "Auth/Yadis/Yadis.php";
4+
5+
function getOpenIDIdentifier()
6+
{
7+
return $_GET['openid_identifier'];
8+
}
9+
10+
function escape($x)
11+
{
12+
return htmlentities($x);
13+
}
14+
15+
16+
$identifier = getOpenIDIdentifier();
17+
?>
18+
<html>
19+
<head>
20+
<title>OpenID discovery</title>
21+
</head>
22+
<body>
23+
<h2>OpenID discovery tool</h2>
24+
<p>
25+
Enter an OpenID URL to begin discovery:
26+
</p>
27+
<form>
28+
<input type="text" name="openid_identifier" size="40" />
29+
<input type="submit" value="Begin" />
30+
</form>
31+
<?
32+
if ($identifier) {
33+
34+
$fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
35+
list($normalized_identifier, $endpoints) = Auth_OpenID_discover(
36+
$identifier, $fetcher);
37+
38+
?>
39+
<h3>Discovery Results for <?= escape($identifier) ?></h3>
40+
41+
<table cellpadding="7" cellspacing="0">
42+
<tbody>
43+
<tr>
44+
<th>Claimed Identifier</th>
45+
<td><?= escape($normalized_identifier) ?></td>
46+
</tr>
47+
<?
48+
if (!$endpoints) {
49+
?>
50+
<tr>
51+
<td colspan="2">No OpenID services discovered.</td>
52+
</tr>
53+
<?
54+
} else {
55+
?>
56+
<tr>
57+
<td colspan="2">Discovered OpenID services:</td>
58+
</tr>
59+
<?
60+
foreach ($endpoints as $endpoint) {
61+
?>
62+
<tr>
63+
<td colspan="2"><hr/></td>
64+
</tr>
65+
<tr>
66+
<th>Server URL</th>
67+
<td><tt><?= escape($endpoint->server_url) ?></tt></td>
68+
</tr>
69+
<tr>
70+
<th>Local ID</th>
71+
<td><tt><?= escape($endpoint->local_id) ?></tt></td>
72+
</tr>
73+
<tr>
74+
<td colspan="2">
75+
<h3>Service types:</h3>
76+
<ul>
77+
<?
78+
foreach ($endpoint->type_uris as $type_uri) {
79+
?>
80+
<li><tt><?= escape($type_uri) ?></tt></li>
81+
<?
82+
}
83+
?>
84+
</ul>
85+
</td>
86+
</tr>
87+
<?
88+
}
89+
}
90+
?>
91+
</tbody>
92+
</table>
93+
<?
94+
}
95+
?>
96+
</body>
97+
</html>

0 commit comments

Comments
 (0)