Skip to content
Snippets Groups Projects
Commit 3401132a authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg
Browse files

upgrded openid server to work with latest janrain library

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@883 44740490-163a-0410-bde0-09ae8108e29a
parent b857b3b1
No related branches found
No related tags found
No related merge requests found
...@@ -57,18 +57,19 @@ $trusted_sites = array( ...@@ -57,18 +57,19 @@ $trusted_sites = array(
* Handle a standard OpenID server request * Handle a standard OpenID server request
*/ */
function action_default() { function action_default() {
SimpleSAML_Logger::debug('OpenID - Provider: action default');
$server =& getServer(); $server =& getServer();
$method = $_SERVER['REQUEST_METHOD']; // $method = $_SERVER['REQUEST_METHOD'];
$request = null; // $request = null;
if ($method == 'GET') { // if ($method == 'GET') {
$request = $_GET; // $request = $_GET;
} else { // } else {
$request = $_POST; // $request = $_POST;
} // }
$request = Auth_OpenID::fixArgs($request); // $request = Auth_OpenID::fixArgs($request);
$request = $server->decodeRequest($request); $request = $server->decodeRequest();
if (!$request) { if (!$request) {
...@@ -105,48 +106,43 @@ function action_default() { ...@@ -105,48 +106,43 @@ function action_default() {
$t->show(); $t->show();
exit(0); exit(0);
} }
setRequestInfo($request); setRequestInfo($request);
if (in_array($request->mode, if (in_array($request->mode,
array('checkid_immediate', 'checkid_setup'))) { array('checkid_immediate', 'checkid_setup'))) {
if (isTrusted($request->identity, $request->trust_root)) { if ($request->idSelect()) {
$response =& $request->answer(true); // Perform IDP-driven identifier selection
$sreg = getSreg($request->identity); if ($request->mode == 'checkid_immediate') {
if (is_array($sreg)) { $response =& $request->answer(false);
foreach ($sreg as $k => $v) { } else {
$response->addField('sreg', $k, $v); return trust_render($request);
}
} }
} else if ((!$request->identity) &&
(!$request->idSelect())) {
// No identifier used or desired; display a page saying
// so.
return noIdentifier_render();
} else if ($request->immediate) { } else if ($request->immediate) {
$response =& $request->answer(false, getServerURL()); $response =& $request->answer(false, buildURL());
} else { } else {
if (!getLoggedInUser()) { if (!getLoggedInUser()) {
// TODO Login check_authenticated_user();
//return login_render(); #return login_render();
check_authenticated_user();
} }
return trust_render($request);
$config = SimpleSAML_Configuration::getInstance();
$t = new SimpleSAML_XHTML_Template($config, 'openid-trust.php');
$t->data['openidurl'] = getLoggedInUser();
$t->data['siteurl'] = htmlspecialchars($request->trust_root);;
$t->data['trusturl'] = buildURL('trust', true);
$t->show();
exit(0);
//return trust_render($request);
} }
} else { } else {
// error_log('request is null' . (is_null($request) ? 'yes' : 'no'));
// error_log('request dump: ' . var_export($request, TRUE) );
$response =& $server->handleRequest($request); $response =& $server->handleRequest($request);
} }
// error_log('response is null' . (is_null($response) ? 'yes' : 'no'));
$webresponse =& $server->encodeResponse($response); $webresponse =& $server->encodeResponse($response);
...@@ -156,13 +152,16 @@ function action_default() { ...@@ -156,13 +152,16 @@ function action_default() {
header(header_connection_close); header(header_connection_close);
print $webresponse->body; print $webresponse->body;
exit(0); exit(0);
} }
/** /**
* Log out the currently logged in user * Log out the currently logged in user
*/ */
function action_logout() { function action_logout() {
SimpleSAML_Logger::debug('OpenID - Provider: action logout');
setLoggedInUser(null); setLoggedInUser(null);
setRequestInfo(null); setRequestInfo(null);
return authCancel(null); return authCancel(null);
...@@ -170,9 +169,17 @@ function action_logout() { ...@@ -170,9 +169,17 @@ function action_logout() {
function trust_render($request) {
$config = SimpleSAML_Configuration::getInstance();
$t = new SimpleSAML_XHTML_Template($config, 'openid-trust.php');
$t->data['openidurl'] = getLoggedInUser();
$t->data['siteurl'] = htmlspecialchars($request->trust_root);;
$t->data['trusturl'] = buildURL('trust', true);
$t->show();
}
function check_authenticated_user() { function check_authenticated_user() {
SimpleSAML_Logger::debug('OpenID - Provider: check authenticated user() ');
//session_start(); //session_start();
...@@ -218,7 +225,7 @@ function check_authenticated_user() { ...@@ -218,7 +225,7 @@ function check_authenticated_user() {
* Log in a user and potentially continue the requested identity approval * Log in a user and potentially continue the requested identity approval
*/ */
function action_login() { function action_login() {
SimpleSAML_Logger::info('OpenID - Provider: action login'); SimpleSAML_Logger::debug('OpenID - Provider: action login');
check_authenticated_user(); check_authenticated_user();
$info = getRequestInfo(); $info = getRequestInfo();
return doAuth($info); return doAuth($info);
...@@ -229,8 +236,8 @@ function action_login() { ...@@ -229,8 +236,8 @@ function action_login() {
/** /**
* Ask the user whether he wants to trust this site * Ask the user whether he wants to trust this site
*/ */
function action_trust() function action_trust() {
{ SimpleSAML_Logger::debug('OpenID - Provider: action trust');
$info = getRequestInfo(); $info = getRequestInfo();
$trusted = isset($_POST['trust']); $trusted = isset($_POST['trust']);
if ($info && isset($_POST['remember'])) { if ($info && isset($_POST['remember'])) {
...@@ -242,6 +249,7 @@ function action_trust() ...@@ -242,6 +249,7 @@ function action_trust()
} }
function action_sites() { function action_sites() {
SimpleSAML_Logger::debug('OpenID - Provider: action sites');
$sites = getSessionSites(); $sites = getSessionSites();
if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($_SERVER['REQUEST_METHOD'] == 'POST') {
...@@ -297,8 +305,7 @@ function redirect_render($redir_url) { ...@@ -297,8 +305,7 @@ function redirect_render($redir_url) {
/** /**
* Get the URL of the current script * Get the URL of the current script
*/ */
function getServerURL() function getServerURL() {
{
$path = $_SERVER['SCRIPT_NAME']; $path = $_SERVER['SCRIPT_NAME'];
$host = $_SERVER['HTTP_HOST']; $host = $_SERVER['HTTP_HOST'];
$port = $_SERVER['SERVER_PORT']; $port = $_SERVER['SERVER_PORT'];
...@@ -315,8 +322,7 @@ function getServerURL() ...@@ -315,8 +322,7 @@ function getServerURL()
/** /**
* Build a URL to a server action * Build a URL to a server action
*/ */
function buildURL($action=null, $escaped=true) function buildURL($action=null, $escaped=true) {
{
$url = getServerURL(); $url = getServerURL();
if ($action) { if ($action) {
$url .= '/' . $action; $url .= '/' . $action;
...@@ -327,8 +333,7 @@ function buildURL($action=null, $escaped=true) ...@@ -327,8 +333,7 @@ function buildURL($action=null, $escaped=true)
/** /**
* Extract the current action from the request * Extract the current action from the request
*/ */
function getAction() function getAction() {
{
$path_info = @$_SERVER['PATH_INFO']; $path_info = @$_SERVER['PATH_INFO'];
$action = ($path_info) ? substr($path_info, 1) : ''; $action = ($path_info) ? substr($path_info, 1) : '';
$function_name = 'action_' . $action; $function_name = 'action_' . $action;
...@@ -338,8 +343,7 @@ function getAction() ...@@ -338,8 +343,7 @@ function getAction()
/** /**
* Write the response to the request * Write the response to the request
*/ */
function writeResponse($resp) function writeResponse($resp) {
{
list ($headers, $body) = $resp; list ($headers, $body) = $resp;
array_walk($headers, 'header'); array_walk($headers, 'header');
header(header_connection_close); header(header_connection_close);
...@@ -361,8 +365,8 @@ function getServer() ...@@ -361,8 +365,8 @@ function getServer()
/** /**
* Return whether the trust root is currently trusted * Return whether the trust root is currently trusted
*/ */
function isTrusted($identity_url, $trust_root) function isTrusted($identity_url, $trust_root) {
{
// from config.php // from config.php
global $trusted_sites; global $trusted_sites;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment