mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-28 15:49:57 +09:00
17515512: JanRain php-openid library included, normalization fix
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@5137 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
f541dd59b9
commit
658c0e6dbc
219 changed files with 41415 additions and 10 deletions
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
require_once "lib/session.php";
|
||||
require_once "lib/render.php";
|
||||
|
||||
define('about_error_template',
|
||||
'<div class="error">
|
||||
An error occurred when processing your request:
|
||||
<br />
|
||||
%s
|
||||
</div>');
|
||||
|
||||
define('about_body',
|
||||
'<p>
|
||||
This is an <a href="http://www.openid.net/">OpenID</a> server
|
||||
endpoint. This server is built on the <a
|
||||
href="http://www.openidenabled.com/openid/libraries/php">JanRain PHP OpenID
|
||||
library</a>. Since OpenID consumer sites will need to directly contact this
|
||||
server, it must be accessible over the Internet (not behind a firewall).
|
||||
</p>
|
||||
<p>
|
||||
To use this server, you will have to set up a URL to use as an identifier.
|
||||
Insert the following markup into the <code><head></code> of the HTML
|
||||
document at that URL:
|
||||
</p>
|
||||
<pre><link rel="openid.server" href="%s" /></pre>
|
||||
<p>
|
||||
Then configure this server so that you can log in with that URL. Once you
|
||||
have configured the server, and marked up your identity URL, you can verify
|
||||
that it is working by using the <a href="http://www.openidenabled.com/"
|
||||
>openidenabled.com</a>
|
||||
<a href="http://www.openidenabled.com/resources/openid-test/checkup">OpenID
|
||||
Checkup tool</a>:
|
||||
<form method="post"
|
||||
action="http://www.openidenabled.com/resources/openid-test/checkup/start">
|
||||
<label for="checkup">OpenID URL:
|
||||
</label><input id="checkup" type="text" name="openid_url" />
|
||||
<input type="submit" value="Check" />
|
||||
</form>
|
||||
</p>
|
||||
');
|
||||
|
||||
/**
|
||||
* Render the about page, potentially with an error message
|
||||
*/
|
||||
function about_render($error=false, $internal=true)
|
||||
{
|
||||
$headers = array();
|
||||
$body = sprintf(about_body, buildURL());
|
||||
if ($error) {
|
||||
$headers[] = $internal ? http_internal_error : http_bad_request;
|
||||
$body .= sprintf(about_error_template, htmlspecialchars($error));
|
||||
}
|
||||
$current_user = getLoggedInUser();
|
||||
return page_render($body, $current_user, 'OpenID Server Endpoint');
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
require_once "lib/session.php";
|
||||
require_once "lib/render.php";
|
||||
|
||||
define('login_form_pat',
|
||||
'<div class="form">
|
||||
<p>
|
||||
Enter your identity URL and password into this form to log in to
|
||||
this server. This server must be configured to accept your identity URL.
|
||||
</p>
|
||||
|
||||
<form method="post" action="%s">
|
||||
<table>
|
||||
<tr>
|
||||
<th><label for="openid_url">OpenID URL:</label></th>
|
||||
<td><input type="text" name="openid_url"
|
||||
value="%s" id="openid_url" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><label for="password">Password:</label></th>
|
||||
<td><input type="password" name="password" id="password" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input type="submit" value="Log in" />
|
||||
<input type="submit" name="cancel" value="Cancel" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
');
|
||||
|
||||
define('login_needed_pat',
|
||||
'You must be logged in as %s to approve this request.');
|
||||
|
||||
function login_render($errors=null, $input=null, $needed=null)
|
||||
{
|
||||
$current_user = getLoggedInUser();
|
||||
if ($input === null) {
|
||||
$input = $current_user;
|
||||
}
|
||||
if ($needed) {
|
||||
$errors[] = sprintf(login_needed_pat, link_render($needed));
|
||||
}
|
||||
|
||||
$esc_input = htmlspecialchars($input, ENT_QUOTES);
|
||||
$login_url = buildURL('login', true);
|
||||
$body = sprintf(login_form_pat, $login_url, $esc_input);
|
||||
if ($errors) {
|
||||
$body = loginError_render($errors) . $body;
|
||||
}
|
||||
return page_render($body, $current_user, 'Log In', null, true);
|
||||
}
|
||||
|
||||
function loginError_render($errors)
|
||||
{
|
||||
$text = '';
|
||||
foreach ($errors as $error) {
|
||||
$text .= sprintf("<li>%s</li>\n", $error);
|
||||
}
|
||||
return sprintf("<ul class=\"error\">\n%s</ul>\n", $text);
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
require_once "lib/session.php";
|
||||
|
||||
define('sites_form',
|
||||
'<p>These decisions have been remembered for this session. All decisions
|
||||
will be forgotten when the session ends.</p>
|
||||
<div class="form">
|
||||
<form method="post" action="%s">
|
||||
<table>
|
||||
<tbody>
|
||||
%s
|
||||
</tbody>
|
||||
</table>
|
||||
<input type="submit" name="remove" value="Remove Selected" />
|
||||
<input type="submit" name="refresh" value="Refresh List" />
|
||||
<input type="submit" name="forget" value="Forget All" />
|
||||
</form>
|
||||
</div>
|
||||
');
|
||||
|
||||
define('sites_empty_message',
|
||||
'<p>
|
||||
No sites are remembered for this session. When you authenticate with a site,
|
||||
you can choose to add it to this list by choosing <q>Remember this
|
||||
decision</q>.
|
||||
</p>
|
||||
<p>%s</p>
|
||||
');
|
||||
|
||||
define('sites_row',
|
||||
'<tr>
|
||||
<td><input type="checkbox" name=%s value="%s" id=%s /></td>
|
||||
<td><label for=%s><code>%s</code></label></td>
|
||||
</tr>');
|
||||
|
||||
function siteListRow_render($i, $site)
|
||||
{
|
||||
$esc_site = htmlspecialchars($site, ENT_QUOTES);
|
||||
$id = sprintf('"site%s"', $i);
|
||||
return sprintf(sites_row, $id, $esc_site, $id, $id, $esc_site);
|
||||
}
|
||||
|
||||
function siteList_render($sites)
|
||||
{
|
||||
$trusted_sites = array();
|
||||
$untrusted_sites = array();
|
||||
foreach ($sites as $site => $trusted) {
|
||||
if ($trusted) {
|
||||
$trusted_sites[] = $site;
|
||||
} else {
|
||||
$untrusted_sites[] = $site;
|
||||
}
|
||||
}
|
||||
$rows = '';
|
||||
$i = 0;
|
||||
foreach (array('Trusted Sites' => $trusted_sites,
|
||||
'Untrusted Sites' => $untrusted_sites) as
|
||||
$name => $sites) {
|
||||
if ($sites) {
|
||||
$rows .= '<tr><th colspan="2">'. $name . '</th></tr>';
|
||||
foreach ($sites as $site) {
|
||||
$rows .= siteListRow_render($i, $site);
|
||||
$i += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
function sites_render($sites)
|
||||
{
|
||||
if ($sites) {
|
||||
$rows = siteList_render($sites);
|
||||
$form = sprintf(sites_form, buildURL('sites'), $rows);
|
||||
$body = $pre . $form;
|
||||
} else {
|
||||
$body = sprintf(sites_empty_message, link_render(buildURL(''), 'Return home'));
|
||||
}
|
||||
return page_render($body, getLoggedInUser(), 'Remembered Sites');
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
require_once "lib/session.php";
|
||||
require_once "lib/render.php";
|
||||
|
||||
define('trust_form_pat',
|
||||
'<div class="form">
|
||||
<p>Do you wish to confirm your identity URL (<code>%s</code>) with <code>%s</code>?</p>
|
||||
<form method="post" action="%s">
|
||||
<input type="checkbox" name="remember" value="on" id="remember"><label
|
||||
for="remember">Remember this decision</label>
|
||||
<br />
|
||||
<input type="submit" name="trust" value="Confirm" />
|
||||
<input type="submit" value="Do not confirm" />
|
||||
</form>
|
||||
</div>
|
||||
');
|
||||
|
||||
function trust_render($info)
|
||||
{
|
||||
$current_user = getLoggedInUser();
|
||||
$lnk = link_render($current_user);
|
||||
$trust_root = htmlspecialchars($info->trust_root);
|
||||
$trust_url = buildURL('trust', true);
|
||||
$form = sprintf(trust_form_pat, $lnk, $trust_root, $trust_url);
|
||||
return page_render($form, $current_user, 'Trust This Site');
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue