mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-30 00:29:58 +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
41
modules/member/php-openid-1.2.3/examples/consumer/common.php
Normal file
41
modules/member/php-openid-1.2.3/examples/consumer/common.php
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
$path_extra = dirname(dirname(dirname(__FILE__)));
|
||||
$path = ini_get('include_path');
|
||||
$path = $path_extra . PATH_SEPARATOR . $path;
|
||||
ini_set('include_path', $path);
|
||||
|
||||
/**
|
||||
* Require the OpenID consumer code.
|
||||
*/
|
||||
require_once "Auth/OpenID/Consumer.php";
|
||||
|
||||
/**
|
||||
* Require the "file store" module, which we'll need to store OpenID
|
||||
* information.
|
||||
*/
|
||||
require_once "Auth/OpenID/FileStore.php";
|
||||
|
||||
/**
|
||||
* This is where the example will store its OpenID information. You
|
||||
* should change this path if you want the example store to be created
|
||||
* elsewhere. After you're done playing with the example script,
|
||||
* you'll have to remove this directory manually.
|
||||
*/
|
||||
$store_path = "/tmp/_php_consumer_test";
|
||||
|
||||
if (!file_exists($store_path) &&
|
||||
!mkdir($store_path)) {
|
||||
print "Could not create the FileStore directory '$store_path'. ".
|
||||
" Please check the effective permissions.";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$store = new Auth_OpenID_FileStore($store_path);
|
||||
|
||||
/**
|
||||
* Create a consumer object using the store object created earlier.
|
||||
*/
|
||||
$consumer = new Auth_OpenID_Consumer($store);
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
require_once "common.php";
|
||||
session_start();
|
||||
|
||||
// Complete the authentication process using the server's response.
|
||||
$response = $consumer->complete($_GET);
|
||||
|
||||
if ($response->status == Auth_OpenID_CANCEL) {
|
||||
// This means the authentication was cancelled.
|
||||
$msg = 'Verification cancelled.';
|
||||
} else if ($response->status == Auth_OpenID_FAILURE) {
|
||||
$msg = "OpenID authentication failed: " . $response->message;
|
||||
} else if ($response->status == Auth_OpenID_SUCCESS) {
|
||||
// This means the authentication succeeded.
|
||||
$openid = $response->identity_url;
|
||||
$esc_identity = htmlspecialchars($openid, ENT_QUOTES);
|
||||
$success = sprintf('You have successfully verified ' .
|
||||
'<a href="%s">%s</a> as your identity.',
|
||||
$esc_identity, $esc_identity);
|
||||
|
||||
if ($response->endpoint->canonicalID) {
|
||||
$success .= ' (XRI CanonicalID: '.$response->endpoint->canonicalID.') ';
|
||||
}
|
||||
|
||||
$sreg = $response->extensionResponse('sreg');
|
||||
|
||||
if (@$sreg['email']) {
|
||||
$success .= " You also returned '".$sreg['email']."' as your email.";
|
||||
}
|
||||
if (@$sreg['postcode']) {
|
||||
$success .= " Your postal code is '".$sreg['postcode']."'";
|
||||
}
|
||||
}
|
||||
|
||||
include 'index.php';
|
||||
|
||||
?>
|
||||
59
modules/member/php-openid-1.2.3/examples/consumer/index.php
Normal file
59
modules/member/php-openid-1.2.3/examples/consumer/index.php
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<html>
|
||||
<head><title>PHP OpenID Authentication Example</title></head>
|
||||
<style type="text/css">
|
||||
* {
|
||||
font-family: verdana,sans-serif;
|
||||
}
|
||||
body {
|
||||
width: 50em;
|
||||
margin: 1em;
|
||||
}
|
||||
div {
|
||||
padding: .5em;
|
||||
}
|
||||
table {
|
||||
margin: none;
|
||||
padding: none;
|
||||
}
|
||||
.alert {
|
||||
border: 1px solid #e7dc2b;
|
||||
background: #fff888;
|
||||
}
|
||||
.success {
|
||||
border: 1px solid #669966;
|
||||
background: #88ff88;
|
||||
}
|
||||
.error {
|
||||
border: 1px solid #ff0000;
|
||||
background: #ffaaaa;
|
||||
}
|
||||
#verify-form {
|
||||
border: 1px solid #777777;
|
||||
background: #dddddd;
|
||||
margin-top: 1em;
|
||||
padding-bottom: 0em;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<h1>PHP OpenID Authentication Example</h1>
|
||||
<p>
|
||||
This example consumer uses the <a
|
||||
href="http://www.openidenabled.com/openid/libraries/php/">PHP
|
||||
OpenID</a> library. It just verifies that the URL that you enter
|
||||
is your identity URL.
|
||||
</p>
|
||||
|
||||
<?php if (isset($msg)) { print "<div class=\"alert\">$msg</div>"; } ?>
|
||||
<?php if (isset($error)) { print "<div class=\"error\">$error</div>"; } ?>
|
||||
<?php if (isset($success)) { print "<div class=\"success\">$success</div>"; } ?>
|
||||
|
||||
<div id="verify-form">
|
||||
<form method="get" action="try_auth.php">
|
||||
Identity URL:
|
||||
<input type="hidden" name="action" value="verify" />
|
||||
<input type="text" name="openid_url" value="" />
|
||||
<input type="submit" value="Verify" />
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
require_once "common.php";
|
||||
session_start();
|
||||
|
||||
// Render a default page if we got a submission without an openid
|
||||
// value.
|
||||
if (empty($_GET['openid_url'])) {
|
||||
$error = "Expected an OpenID URL.";
|
||||
include 'index.php';
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$scheme = 'http';
|
||||
if (isset($_SERVER['HTTPS']) and $_SERVER['HTTPS'] == 'on') {
|
||||
$scheme .= 's';
|
||||
}
|
||||
|
||||
$openid = $_GET['openid_url'];
|
||||
$process_url = sprintf("$scheme://%s:%s%s/finish_auth.php",
|
||||
$_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'],
|
||||
dirname($_SERVER['PHP_SELF']));
|
||||
|
||||
$trust_root = sprintf("$scheme://%s:%s%s",
|
||||
$_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'],
|
||||
dirname($_SERVER['PHP_SELF']));
|
||||
|
||||
// Begin the OpenID authentication process.
|
||||
$auth_request = $consumer->begin($openid);
|
||||
|
||||
// Handle failure status return values.
|
||||
if (!$auth_request) {
|
||||
$error = "Authentication error.";
|
||||
include 'index.php';
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$auth_request->addExtensionArg('sreg', 'optional', 'email');
|
||||
|
||||
// Redirect the user to the OpenID server for authentication. Store
|
||||
// the token for this authentication so we can verify the response.
|
||||
|
||||
$redirect_url = $auth_request->redirectURL($trust_root,
|
||||
$process_url);
|
||||
|
||||
header("Location: ".$redirect_url);
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue