summaryrefslogtreecommitdiffstats
path: root/php
diff options
context:
space:
mode:
authorChristophe Nowicki <cnowicki@easter-eggs.com>2004-09-17 16:02:24 +0000
committerChristophe Nowicki <cnowicki@easter-eggs.com>2004-09-17 16:02:24 +0000
commit1db82e571dd29835ee669472de1a646314e12aa9 (patch)
treea5327193d410a974e21dc27e6554420c5bec8a1b /php
parentcc5bffb4bd9a1f3f057be78bfcd71db51a74dfc8 (diff)
downloadlasso-1db82e571dd29835ee669472de1a646314e12aa9.tar.gz
lasso-1db82e571dd29835ee669472de1a646314e12aa9.tar.xz
lasso-1db82e571dd29835ee669472de1a646314e12aa9.zip
log viewer for the Service Provider and the Identity Provider
added logger for in many files updated idp1 metadata, added .php extension added session viewer for the sp (you will be able to view online users)
Diffstat (limited to 'php')
-rw-r--r--php/Attic/examples/sample-idp/admin_user.php23
-rw-r--r--php/Attic/examples/sample-idp/index.php24
-rw-r--r--php/Attic/examples/sample-idp/log_view.php96
-rw-r--r--php/Attic/examples/sample-idp/login.php17
-rw-r--r--php/Attic/examples/sample-idp/setup.php27
-rw-r--r--php/Attic/examples/sample-idp/singleSignOn.php116
-rw-r--r--php/Attic/examples/sample-idp/soapEndpoint.php14
-rw-r--r--php/Attic/examples/sample-idp/user_add.php4
-rw-r--r--php/Attic/examples/sample-sp/assertionConsumer.php111
-rw-r--r--php/Attic/examples/sample-sp/index.php58
-rw-r--r--php/Attic/examples/sample-sp/log_view.php160
-rw-r--r--php/Attic/examples/sample-sp/login.php40
-rw-r--r--php/Attic/examples/sample-sp/logout.php1
-rw-r--r--php/Attic/examples/sample-sp/metadata_idp1.xml8
-rw-r--r--php/Attic/examples/sample-sp/setup.php58
-rw-r--r--php/Attic/examples/sample-sp/view_session.php88
16 files changed, 652 insertions, 193 deletions
diff --git a/php/Attic/examples/sample-idp/admin_user.php b/php/Attic/examples/sample-idp/admin_user.php
index ca5f14ba..0f0c31c3 100644
--- a/php/Attic/examples/sample-idp/admin_user.php
+++ b/php/Attic/examples/sample-idp/admin_user.php
@@ -81,7 +81,8 @@
$res =& $db->query($query);
if (DB::isError($res))
die($res->getMessage());
-
+
+ $logger->log("Delete User '".$_GET['del']."'", PEAR_LOG_NOTICE);
}
lasso_init();
@@ -164,21 +165,21 @@
if ((($count - $startUser) > $number_of_users) && !isset($_GET['show_all']))
echo "<a href=$PHP_SELF?startUser=" . ($startUser + $number_of_users) . ">Next</a>";
else
- echo "Next"
- ?>
- <?php
+ echo "Next";
+
+ if (isset($_GET['show_all']))
+ echo "| <a href=\"" . $PHP_SELF ."?startUser=0\">Paginate</a>";
+ else
+ {
for ($i = 0; $i < $count; $i += $number_of_users)
if ($i == $startUser)
echo "| " . ( $i / $number_of_users);
else
echo "| <a href=\"$PHP_SELF?startUser=$i\">" . ( $i / $number_of_users) . "</a>";
+ if ($count > $number_of_users)
+ echo "| <a href=\"$PHP_SELF?show_all=1\">Show All</a>";
+ }
?>
- |
- <?php if (isset($_GET['show_all'])) { ?>
- <a href="<?php echo $PHP_SELF."?startUser=0"; ?>">Paginate</a>
- <?php } else { ?>
- <a href="<?php echo $PHP_SELF."?show_all=1"; ?>">Show All</a>
- <?php } ?>
| <a href="javascript:void(0)" onClick="ToggleAll();">Toggle All</a></td>
<td align='right'><a href="javascript:openpopup('user_add.php')">add user</a></td>
</tr>
@@ -237,7 +238,7 @@
</td>
</tr>
<tr>
- <td colspan="<?php echo $num_col; ?>" align='center'>
+ <td colspan="<?php echo $num_col; ?>" align='center'>
<?php
// get all federations for this user
if (!empty($session_dump) && !empty($identity_dump))
diff --git a/php/Attic/examples/sample-idp/index.php b/php/Attic/examples/sample-idp/index.php
index 44e4570d..2b14c010 100644
--- a/php/Attic/examples/sample-idp/index.php
+++ b/php/Attic/examples/sample-idp/index.php
@@ -22,6 +22,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+ require_once 'DB.php';
+
if(!extension_loaded('lasso')) {
$ret = @dl('lasso.' . PHP_SHLIB_SUFFIX);
if ($ret == FALSE)
@@ -50,13 +52,17 @@ You can get more informations about <b>Lasso</b> at <br>
$config = unserialize(file_get_contents('config.inc'));
- require_once 'DB.php';
+ // connect to the data base
+ $db = &DB::connect($config['dsn']);
+ if (DB::isError($db))
+ die($db->getMessage());
session_start();
lasso_init();
?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Lasso Service Provider Example</title>
@@ -64,15 +70,16 @@ You can get more informations about <b>Lasso</b> at <br>
</head>
<body>
-<p>
+<p align='center'>
<b>Identity Provider Administration</b><br>
<a href="setup.php">Setup</a><br>
- <a href="admin_user.php">Users Management</a>
+ <a href="admin_user.php">Users Management</a><br>
+ <a href="view_sessions.php">View Online Users</a>
<?php if ($config['log_handler'] == 'sql') { ?>
<br><a href="log_view.php">View log</a>
<?php } ?>
</p>
-<p>
+<p align='center'>
<b>Identity Provider Fonctionnality</b><br>
<?php
if (!isset($_SESSION["user_id"])) {
@@ -87,8 +94,8 @@ You can get more informations about <b>Lasso</b> at <br>
<?php } ?>
</p>
-<p>
-<table>
+<p align='center'>
+<table align='center'>
<caption><b>Status</b></caption>
<tr>
<?php
@@ -116,11 +123,12 @@ You can get more informations about <b>Lasso</b> at <br>
</table>
<br>
-<p>Copyright &copy; 2004 Entr'ouvert</p>
+<p align='center'>Copyright &copy; 2004 Entr'ouvert</p>
</body>
</html>
<?php
+ $db->disconnect();
lasso_shutdown();
?>
diff --git a/php/Attic/examples/sample-idp/log_view.php b/php/Attic/examples/sample-idp/log_view.php
index fb68fbdc..68acc458 100644
--- a/php/Attic/examples/sample-idp/log_view.php
+++ b/php/Attic/examples/sample-idp/log_view.php
@@ -37,16 +37,27 @@
$number_of_msg = 8;
+ // Count log messages
+ $query = "SELECT COUNT(*) FROM log";
+ $res =& $db->query($query);
+ if (DB::isError($res))
+ die($res->getMessage());
+
+ $row = $res->fetchRow();
+ $count = $row[0];
+
$startMsg = ((empty($_GET['startMsg'])) ? 0 : $_GET['startMsg']);
- $query = "SELECT * FROM log";
+ $query = "SELECT * FROM log ORDER BY id DESC";
if (!isset($_GET['show_all']))
$query .= " OFFSET $startMsg LIMIT " . ($startMsg + $number_of_msg);
-
+
+
$res =& $db->query($query);
- if (DB::isError($db))
- die($db->getMessage());
+ if (DB::isError($res))
+ die($res->getMessage());
+ $numRows = $res->numRows();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
@@ -54,7 +65,7 @@
<html>
<head>
<head>
- <title>View Logs</title>
+ <title>Lasso Identity Provider Example : View Logs</title>
</head>
<body>
<br>
@@ -62,6 +73,36 @@
<caption>Logged events</caption>
<thead>
<tr>
+ <td colspan='4'>
+ <?php
+ if ($startMsg)
+ echo "<a href=$PHP_SELF?startMsg=" . ($startMsg - $number_of_msg) . ">Previous</a>";
+ else
+ echo "Previous"
+ ?>
+ |
+ <?php
+ if ((($count - $startMsg) > $number_of_users) && !isset($_GET['show_all']))
+ echo "<a href=\"" . $PHP_SELF . "?startMsg=" . ($startMsg + $number_of_msg) . "\">Next</a>";
+ else
+ echo "Next";
+
+ if (isset($_GET['show_all']))
+ echo "| <a href=\"" . $PHP_SELF ."?startMsg=0\">Paginate</a>";
+ else
+ {
+ for ($i = 0; $i < $count; $i += $number_of_msg)
+ if ($i == $startMsg)
+ echo "| " . ( $i / $number_of_msg);
+ else
+ echo "| <a href=\"$PHP_SELF?startMsg=$i\">" . ( $i / $number_of_msg) . "</a>";
+ if ($count > $number_of_msg)
+ echo "| <a href=\"$PHP_SELF?show_all=1\">Show All</a>";
+ }
+ ?>
+ </td>
+</tr>
+<tr>
<td align='center'>date</td>
<td align='center'>filename</td>
<td align='center'>priority</td>
@@ -70,38 +111,49 @@
</thead>
<tbody>
<?php
- $num_col = $res->numCols();
- $tableinfo = $db->tableInfo($res);
+ if ($numRows)
+ {
+ $num_col = $res->numCols();
+ $tableinfo = $db->tableInfo($res);
- $desc = array("emergency", "alert", "critical", "error", "warning", "notice", "informational", "debug");
+ $desc = array("emergency", "alert", "critical", "error", "warning", "notice", "informational", "debug");
- while($row = $res->fetchRow())
- {
- echo "<tr>";
- for ($i = 0; $i < $num_col; $i++)
+ while($row = $res->fetchRow())
{
- switch ($tableinfo[$i]['name'])
+ echo "<tr>";
+ for ($i = 0; $i < $num_col; $i++)
{
- case "id":
- break;
- case "priority":
- echo "<td align='center'>" . $desc[$row[$i]] . "</td>";
- break;
- default:
- echo "<td align='center'>" . $row[$i] . "</td>";
+ switch ($tableinfo[$i]['name'])
+ {
+ case "id":
+ break;
+ case "priority":
+ echo "<td align='center'>" . $desc[$row[$i]] . "</td>";
+ break;
+ case "message":
+ echo "<td>" . $row[$i] . "</td>";
+ break;
+ default:
+ echo "<td align='center'>" . $row[$i] . "</td>";
+ }
}
+ echo "</tr>";
}
- echo "</tr>";
}
?>
<tr>
</tr>
</tbody>
<tfoot>
-<td colspan='5'>&nbsp;</td>
+<tr>
+ <td colspan='4'>&nbsp;</td>
+</tr>
</tfoot>
</table>
<br>
+<p align='center'><a href='index.php'>Index</a>
+</p>
+<br>
<p>Copyright &copy; 2004 Entr'ouvert</p>
</body>
</html>
diff --git a/php/Attic/examples/sample-idp/login.php b/php/Attic/examples/sample-idp/login.php
index 21b196f9..db24681e 100644
--- a/php/Attic/examples/sample-idp/login.php
+++ b/php/Attic/examples/sample-idp/login.php
@@ -37,6 +37,8 @@
$conf['db'] = $db;
$logger = &Log::factory($config['log_handler'], 'log', $_SERVER['PHP_SELF'], $conf);
+ session_start();
+
/*
*
*/
@@ -67,7 +69,7 @@
$logger->log("DB Error :" . $db->getMessage(), PEAR_LOG_CRIT);
$logger->log("DB Error :" . $db->getDebugInfo(), PEAR_LOG_DEBUG);
die("Internal Server Error");
- }
+ } send by
if ($res->numRows())
{
@@ -90,17 +92,17 @@
// Check Login and Password
if (!($user_id = authentificateUser($db, $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])))
{
- $logger->log("Authentication failure with login '".$form->exportValue('username')." password '". $form->exportValue('password') ."' IP '" . $_SERVER['REMOTE_ADDR']."'", PEAR_LOG_WARNING);
+ $logger->log("Authentication failure with login '".$form->exportValue('username')." password '". $form->exportValue('password') ."' IP " . $_SERVER['REMOTE_ADDR'], PEAR_LOG_WARNING);
sendHTTPBasicAuth();
$db->disconnect();
exit;
}
else
{
- $_SESSION['user_id'] = $user_id;
- $_SESSION['username'] = $_SERVER['PHP_AUTH_USER'];
-
- $logger->log("User '".$_SERVER['PHP_AUTH_USER']."'($user_id) authenticated, local session started", PEAR_LOG_NOTICE);
+ $_SESSION['user_id'] = $user_id;
+ $_SESSION['username'] = $_SERVER['PHP_AUTH_USER'];
+
+ $logger->log("User '".$_SERVER['PHP_AUTH_USER']."' ($user_id) authenticated, local session started", PEAR_LOG_NOTICE);
/* TODO : load identity and session dump
@@ -148,11 +150,10 @@
{
if (($user_id = authentificateUser($db, $form->exportValue('username'), $form->exportValue('password'))))
{
- session_start();
$_SESSION['user_id'] = $user_id;
$_SESSION['username'] = $form->exportValue('username');
- $logger->log("User '".$form->exportValue('username')."'($user_id) authenticated, local session started", PEAR_LOG_NOTICE);
+ $logger->log("User '".$form->exportValue('username')."'($user_id) authenticated, local session started", PEAR_LOG_NOTICE);
$url = 'index.php';
header("Request-URI: $url");
diff --git a/php/Attic/examples/sample-idp/setup.php b/php/Attic/examples/sample-idp/setup.php
index d71de39f..eaa9fa88 100644
--- a/php/Attic/examples/sample-idp/setup.php
+++ b/php/Attic/examples/sample-idp/setup.php
@@ -211,10 +211,11 @@
$query = "CREATE TABLE users (
user_id varchar(100) primary key,
- username varchar(255) unique,
- password varchar(255),
+ username varchar(255) unique,
+ password varchar(255),
identity_dump text,
- session_dump text)";
+ session_dump text,
+ created timestamp)";
$res =& $db->query($query);
if (DB::isError($res))
die($res->getMessage());
@@ -279,6 +280,22 @@
die($res->getMessage());
print "OK";
+
+ print "<br>Create table 'sessions' : ";
+ $query = "DROP TABLE sessions CASCADE";
+ $res =& $db->query($query);
+
+ $query = "CREATE TABLE sessions (
+ id varchar(32) primary key,
+ expiry integer,
+ data text
+ )";
+
+ $res =& $db->query($query);
+ if (DB::isError($res))
+ die($res->getMessage());
+
+ print "OK";
$db->disconnect();
@@ -323,9 +340,7 @@
$config['idp-ca'], lassoSignatureMethodRsaSha1);
if (empty($server))
- {
die("Failed");
- }
else
print "OK";
@@ -368,7 +383,7 @@
$setup = TRUE;
}
$setup_log = ob_get_contents();
- ob_end_clean();
+ ob_end_clean();
?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
diff --git a/php/Attic/examples/sample-idp/singleSignOn.php b/php/Attic/examples/sample-idp/singleSignOn.php
index 9623e32c..96dc50b2 100644
--- a/php/Attic/examples/sample-idp/singleSignOn.php
+++ b/php/Attic/examples/sample-idp/singleSignOn.php
@@ -56,32 +56,37 @@
}
else
{
- $login = new LassoLogin($server);
-
- // init login
- updateDumpsFromSession($login);
- initFromAuthnRequest($login);
-
-
-
- // User must *NOT* Authenticate with the IdP
- if (!$login->mustAuthenticate())
- {
- $user_id = authentificateUser($db, $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
- if (!$user_id)
- die("Unknown User");
+ $login = new LassoLogin($server);
+
+ // init login
+ updateDumpsFromSession($login);
+ initFromAuthnRequest($login);
+
+
+ // User must *NOT* Authenticate with the IdP
+ if (!$login->mustAuthenticate())
+ {
+ $user_id = authentificateUser($db, $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
+ if (!$user_id)
+ {
+ $logger->log("User must not authenticate, username and password are not available", PEAR_LOG_CRIT);
+ die("Unknown User");
+ }
- $array = getIdentityDumpAndSessionDumpFromUserID($db, $user_id);
- if (empty($array))
- die("Could not get Identity and Session Dump");
-
- $login->setIdentityFromDump($array['identity_dump']);
- $login->setSessionFromDump($array['session_dump']);
+ $array = getIdentityDumpAndSessionDumpFromUserID($db, $user_id);
+ if (empty($array))
+ {
+ $logger->log("User must no authenticate, but I don't find session and identity dump in the database", PEAR_LOG_CRIT);
+ die("Could not get Identity and Session Dump");
+ }
+
+ $login->setIdentityFromDump($array['identity_dump']);
+ $login->setSessionFromDump($array['session_dump']);
- doneSingleSignOn($db, $login, $user_id);
- $db->disconnect();
- exit;
- }
+ doneSingleSignOn($db, $login, $user_id);
+ $db->disconnect();
+ exit;
+ }
// Check Login and Password
if (!($user_id = authentificateUser($db, $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])))
@@ -206,12 +211,20 @@
*/
function updateDumpsFromSession(&$login)
{
+ global $logger;
+
// Get session and identity dump if there are available
if (!empty($_SESSION['session_dump']))
+ {
+ $logger->log("Update user's session dump", PEAR_LOG_DEBUG);
$login->setSessionFromDump($_SESSION['session_dump']);
+ }
if (!empty($_SESSION['identity_dump']))
+ {
+ $logger->log("Update user's identity dump", PEAR_LOG_DEBUG);
$login->setIdentityFromDump($_SESSION['identity_dump']);
+ }
}
/*
@@ -237,12 +250,18 @@
*/
function authentificateUser($db, $username, $password)
{
+ global $logger;
+
$query = "SELECT user_id FROM users WHERE username=".$db->quoteSmart($username);
$query .= " AND password=".$db->quoteSmart($password);
$res =& $db->query($query);
if (DB::isError($res))
+ {
+ $logger->log("DB Error :" . $db->getMessage(), PEAR_LOG_CRIT);
+ $logger->log("DB Error :" . $db->getDebugInfo(), PEAR_LOG_DEBUG);
die($res->getMessage());
+ }
if ($res->numRows())
{
@@ -259,11 +278,15 @@
function getUserIDFromNameIdentifier($db, $nameidentifier)
{
$query = "SELECT user_id FROM nameidentifiers WHERE name_identifier='$nameidentifier'";
- echo $query;
+ // echo $query;
$res =& $db->query($query);
- if (DB::isError($res))
- die($res->getMessage());
+ if (DB::isError($res))
+ {
+ $logger->log("DB Error :" . $db->getMessage(), PEAR_LOG_CRIT);
+ $logger->log("DB Error :" . $db->getDebugInfo(), PEAR_LOG_DEBUG);
+ die($res->getMessage());
+ }
// UserID not found
if (!$res->numRows())
@@ -289,8 +312,8 @@
if ($res->numRows())
{
$row =& $res->fetchRow();
- $ret = array("identity_dump" => $row[0], "session_dump" => $row[1]);
- return ($ret);
+ $ret = array("identity_dump" => $row[0], "session_dump" => $row[1]);
+ return ($ret);
}
}
@@ -300,32 +323,24 @@
*/
function doneSingleSignOn($db, &$login, $user_id, $is_first_sso = FALSE)
{
+ global $logger;
+
$authenticationMethod =
(($_SERVER["HTTPS"] == 'on') ? lassoSamlAuthenticationMethodSecureRemotePassword : lassoSamlAuthenticationMethodPassword);
// reauth in session_cache_expire, default is 180 minutes
$reauthenticateOnOrAfter = strftime("%Y-%m-%dT%H:%M:%SZ", time() + session_cache_expire() * 60);
- /* FIXME : there is a segfault when I use a switch statement
- switch($login->protocolProfile)
- {
- case lassoLoginProtocolProfileBrwsArt:
- $login->buildArtifactMsg(TRUE, // User is authenticated
- $authenticationMethod, $reauthenticateOnOrAfter, lassoHttpMethodRedirect);
- break;
- case lassoLoginProtocolProfileBrwsPost:
- die("TODO : Post\n");
- default:
- die("Unknown protocol profile\n");
- } */
-
if ($login->protocolProfile == lassoLoginProtocolProfileBrwsArt)
$login->buildArtifactMsg(TRUE, // User is authenticated
$authenticationMethod, $reauthenticateOnOrAfter, lassoHttpMethodRedirect);
else if ($login->protocolProfile == lassoLoginProtocolProfileBrwsPost)
die("TODO : Post\n"); // TODO
else
- die("Unknown protocol profile\n");
+ {
+ $logger->log("Unknown protocol profile", PEAR_LOG_CRIT);
+ die("Unknown protocol profile\n");
+ }
if ($is_first_sso)
{
@@ -335,23 +350,30 @@
$res =& $db->query($query);
if (DB::isError($res))
- die($res->getMessage());
+ {
+ $logger->log("DB Error :" . $db->getMessage(), PEAR_LOG_CRIT);
+ $logger->log("DB Error :" . $db->getDebugInfo(), PEAR_LOG_DEBUG);
+ die($res->getMessage());
+ }
}
$identity = $login->identity;
// do we need to update identity dump?
if ($login->isIdentityDirty)
- updateIdentityDump($db, $user_id, $identity->dump());
+ updateIdentityDump($db, $user_id, $identity->dump());
$session = $login->session;
// do we need to update session dump?
if ($login->isSessionDirty)
- updateSessionDump($db, $user_id, $session->dump());
+ updateSessionDump($db, $user_id, $session->dump());
if (empty($login->assertionArtifact))
+ {
+ $logger->log("Assertion Artifact is empty", PEAR_LOG_CRIT);
die("assertion Artifact is empty");
+ }
- saveAssertionArtifact($db, $login->assertionArtifact, $login->assertion);
+ saveAssertionArtifact($db, $login->assertionArtifact, $login->assertion);
unset($_SESSION['login_dump']); // delete login_dump
$_SESSION['identity_dump'] = $session->dump();
diff --git a/php/Attic/examples/sample-idp/soapEndpoint.php b/php/Attic/examples/sample-idp/soapEndpoint.php
index 887a5063..9172e9fd 100644
--- a/php/Attic/examples/sample-idp/soapEndpoint.php
+++ b/php/Attic/examples/sample-idp/soapEndpoint.php
@@ -1,6 +1,5 @@
<?php
/*
- *
* Identity Provider Example -- SOAP Endpoint
*
* Copyright (C) 2004 Entr'ouvert
@@ -25,12 +24,19 @@
require_once 'Log.php';
require_once 'DB.php';
+ $config = unserialize(file_get_contents('config.inc'));
+
+ $server_dump = file_get_contents($config['server_dump_filename']);
+
header("Content-Type: text/xml\r\n");
// connect to the data base
$db = &DB::connect($config['dsn']);
if (DB::isError($db))
- die("Could not connect to the database");
+ {
+ header("HTTP/1.0 500 Internal Server Error");
+ exit;
+ }
// create logger
$conf['db'] = $db;
@@ -42,10 +48,6 @@
die("HTTP_RAW_POST_DATA is empty!");
}
- $config = unserialize(file_get_contents('config.inc'));
-
- $server_dump = file_get_contents($config['server_dump_filename']);
-
lasso_init();
$requestype = lasso_getRequestTypeFromSoapMsg($HTTP_RAW_POST_DATA);
diff --git a/php/Attic/examples/sample-idp/user_add.php b/php/Attic/examples/sample-idp/user_add.php
index 014677b1..ce451431 100644
--- a/php/Attic/examples/sample-idp/user_add.php
+++ b/php/Attic/examples/sample-idp/user_add.php
@@ -50,9 +50,9 @@
if ($form->validate())
{
- $query = "INSERT INTO users (user_id, username, password) VALUES(nextval('user_id_seq'),";
+ $query = "INSERT INTO users (user_id, username, password, created) VALUES(nextval('user_id_seq'),";
$query .= $db->quoteSmart($form->exportValue('username')) . ",";
- $query .= $db->quoteSmart($form->exportValue('password')) . ")";
+ $query .= $db->quoteSmart($form->exportValue('password')) . ", NOW())";
$res =& $db->query($query);
if (DB::isError($res))
diff --git a/php/Attic/examples/sample-sp/assertionConsumer.php b/php/Attic/examples/sample-sp/assertionConsumer.php
index 7ae2c7a8..85d67556 100644
--- a/php/Attic/examples/sample-sp/assertionConsumer.php
+++ b/php/Attic/examples/sample-sp/assertionConsumer.php
@@ -22,24 +22,36 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
- $config = unserialize(file_get_contents('config.inc'));
-
+ require_once 'Log.php';
require_once 'DB.php';
+
+ $config = unserialize(file_get_contents('config.inc'));
+
if (!$_GET['SAMLart']) {
exit(1);
}
-
+
+ $db = &DB::connect($config['dsn']);
+
+ if (DB::isError($db))
+ die($db->getMessage());
+
+ // create logger
+ $conf['db'] = $db;
+ $logger = &Log::factory($config['log_handler'], 'log', $_SERVER['PHP_SELF'], $conf);
+
session_start();
lasso_init();
$server_dump = file_get_contents($config['server_dump_filename']);
- $server = LassoServer::newfromdump($server_dump);
+ $server = LassoServer::newFromDump($server_dump);
$login = new LassoLogin($server);
+ $logger->log('Request from ' . $_SERVER['REMOTE_ADDR'], PEAR_LOG_INFO);
$login->initRequest($_SERVER['QUERY_STRING'], lassoHttpMethodRedirect);
$login->buildRequestMsg();
@@ -49,6 +61,9 @@
"POST %s HTTP/1.1\r\nHost: %s:%d\r\nContent-Length: %d\r\nContent-Type: text/xml\r\n\r\n%s\r\n",
$url['path'], $url['host'], $url['port'], strlen($login->msgBody), $login->msgBody);
+ $logger->log('Send SOAP Request to '. $url['host'] . ":" .$url['port']. $url['path'], PEAR_LOG_INFO);
+ $logger->log('SOAP Request : ' . $soap, PEAR_LOG_DEBUG);
+
# PHP 4.3.0 with OpenSSL support required
$fp = fsockopen("ssl://" . $url['host'], $url['port'], $errno, $errstr, 30) or die($errstr ($errno));
socket_set_timeout($fp, 10);
@@ -78,41 +93,50 @@
else
{
if (preg_match('/Content\\-Length:\\s+([0-9]+)\\r\\n/', $header, $matches))
- $response = fread($fp, $matches[1]);
+ $response = @fread($fp, $matches[1]);
else
while (!feof($fp)) $response .= fread($fp, 1024);
}
fclose($fp);
+ $logger->log('SOAP Response Header : ' . $header, PEAR_LOG_DEBUG);
+ $logger->log('SOAP Response Body : ' . $response, PEAR_LOG_DEBUG);
+
if (!preg_match("/^HTTP\/1\\.. 200/i", $header)) {
- die("Wrong artifact");
+ $logger->log("Wrong Artifact send by " . $_SERVER['REMOTE_ADDR'], PEAR_LOG_ERR);
+ die("Wrong Artifact");
}
$login->processResponseMsg($response);
-
- $db = &DB::connect($config['dsn']);
-
- if (DB::isError($db))
- die($db->getMessage());
-
+
$query = "SELECT user_id FROM nameidentifiers WHERE name_identifier='" . $login->nameIdentifier . "'";
$res =& $db->query($query);
+ $logger->log("Name Identifier : " . $login->nameIdentifier, PEAR_LOG_DEBUG);
+
if (DB::isError($res))
- die($res->getMessage());
+ {
+ $logger->log("DB Error :" . $db->getMessage(), PEAR_LOG_CRIT);
+ $logger->log("DB Error :" . $db->getDebugInfo(), PEAR_LOG_DEBUG);
+ die($db->getMessage());
+ }
if ($res->numRows() > 0)
{
// User already exist in the database
$row =& $res->fetchRow();
- $user_id = $row[0];
+ $user_id = $row[0];
# Get Identity Dump from the data base
$query = "SELECT identity_dump FROM users WHERE user_id='$user_id'";
$res =& $db->query($query);
if (DB::isError($db))
- die($db->getMessage());
+ {
+ $logger->log("DB Error :" . $db->getMessage(), PEAR_LOG_CRIT);
+ $logger->log("DB Error :" . $db->getDebugInfo(), PEAR_LOG_DEBUG);
+ die($db->getMessage());
+ }
$row =& $res->fetchRow();
@@ -124,11 +148,13 @@
$session = $login->session;
- $_SESSION["nameidentifier"] = $login->nameIdentifier;
- $_SESSION["session_dump"] = $session->dump();
- $_SESSION["user_id"] = $user_id;
+ $_SESSION['nameidentifier'] = $login->nameIdentifier;
+ $_SESSION['session_dump'] = $session->dump();
+ $_SESSION['user_id'] = $user_id;
$url = "index.php";
+
+ $logger->log("New session started for user '$user_id'", PEAR_LOG_INFO);
}
else
{
@@ -141,30 +167,48 @@
$session = $login->session;
// Insert into users
- $identity_dump_quoted = $db->quoteSmart($identity_dump);
- $query = "INSERT INTO users (user_id,identity_dump,created) VALUES(nextval('user_id_seq'), $identity_dump_quoted, NOW())";
+ $query = "INSERT INTO users (user_id,identity_dump,created) VALUES(nextval('user_id_seq'),";
+ $query .= $db->quoteSmart($identity_dump) . ", NOW())";
+
$res =& $db->query($query);
if (DB::isError($res))
- print $res->getMessage(). "\n";
+ {
+ $logger->log("DB Error :" . $db->getMessage(), PEAR_LOG_CRIT);
+ $logger->log("DB Error :" . $db->getDebugInfo(), PEAR_LOG_DEBUG);
+ die($db->getMessage());
+ }
+
// Get UserID
$query = "SELECT last_value FROM user_id_seq";
$res =& $db->query($query);
if (DB::isError($res))
- print $res->getMessage(). "\n";
+ {
+ $logger->log("DB Error :" . $db->getMessage(), PEAR_LOG_CRIT);
+ $logger->log("DB Error :" . $db->getDebugInfo(), PEAR_LOG_DEBUG);
+ die($db->getMessage());
+ }
$row = $res->fetchRow();
$user_id = $row[0];
+ $logger->log("New user($user_id) created", PEAR_LOG_NOTICE);
+
// Insert into nameidentifiers
$query = "INSERT INTO nameidentifiers VALUES('".$login->nameIdentifier."', '$user_id')";
$res =& $db->query($query);
if (DB::isError($res))
- print $res->getMessage(). "\n";
+ {
+ $logger->log("DB Error :" . $db->getMessage(), PEAR_LOG_CRIT);
+ $logger->log("DB Error :" . $db->getDebugInfo(), PEAR_LOG_DEBUG);
+ die($db->getMessage());
+ }
+
+ $_SESSION['nameidentifier'] = $login->nameIdentifier;
+ $_SESSION['session_dump'] = $session->dump();
+ $_SESSION['user_id'] = $user_id;
- $_SESSION["nameidentifier"] = $login->nameIdentifier;
- $_SESSION["session_dump"] = $session->dump();
- $_SESSION["user_id"] = $user_id;
+ $logger->log("New session started for user '$user_id', redirect to the registration form", PEAR_LOG_INFO);
$url = "register.php";
}
@@ -173,14 +217,17 @@
$query = "UPDATE users SET last_login=NOW() WHERE user_id='$user_id'";
$res =& $db->query($query);
if (DB::isError($res))
- print $res->getMessage(). "\n";
-
- $db->disconnect();
-
- lasso_shutdown();
+ {
+ $logger->log("DB Error :" . $db->getMessage(), PEAR_LOG_CRIT);
+ $logger->log("DB Error :" . $db->getDebugInfo(), PEAR_LOG_DEBUG);
+ die($db->getMessage());
+ }
+ $logger->log("Update last login for user '$user_id'", PEAR_LOG_INFO);
header("Request-URI: $url");
header("Content-Location: $url");
- header("Location: $urln\n\n");
+ header("Location: $url\n\n");
+ $db->disconnect();
+ lasso_shutdown();
exit();
?>
diff --git a/php/Attic/examples/sample-sp/index.php b/php/Attic/examples/sample-sp/index.php
index 199e8286..05d16e54 100644
--- a/php/Attic/examples/sample-sp/index.php
+++ b/php/Attic/examples/sample-sp/index.php
@@ -22,6 +22,9 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+ require_once 'HTTP/Session.php';
+ require_once 'DB.php';
+
if(!extension_loaded('lasso')) {
$ret = @dl('lasso.' . PHP_SHLIB_SUFFIX);
if ($ret == FALSE)
@@ -50,14 +53,17 @@ You can get more informations about <b>Lasso</b> at <br>
$config = unserialize(file_get_contents('config.inc'));
- require_once 'DB.php';
-
- session_start();
+ // connect to the data base
+ $db = &DB::connect($config['dsn']);
+ if (DB::isError($db))
+ die($db->getMessage());
+
+ session_start();
- lasso_init();
-
+ lasso_init();
?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Lasso Service Provider Example</title>
@@ -65,19 +71,26 @@ You can get more informations about <b>Lasso</b> at <br>
</head>
<body>
-<p>
+<p align='center'>
<b>Service Provider Administration</b><br>
<a href="setup.php">Setup</a><br>
<a href="admin_user.php">Users Management</a><br>
+<a href="view_session.php">View Online Users</a>
+<?php if ($config['log_handler'] == 'sql') { ?>
+ <br><a href="log_view.php">View log</a>
+<?php } ?>
</p>
-<p>
+<p align='center'>
<b>Serice Provider Fonctionnality</b>
-<table>
+<table align='center'>
<?php
if (!isset($_SESSION["nameidentifier"])) {
?>
<tr>
- <td colspan="2">Single SignOn using an IdP</td>
+ <td colspan="2">Single SignOn using an Identity Provider</td>
+</tr>
+<tr>
+ <td colspan="2">&nbsp;</td>
</tr>
<tr>
<td>Provider</td>
@@ -85,7 +98,7 @@ You can get more informations about <b>Lasso</b> at <br>
</tr>
<tr>
<td><?php echo $config['providerID']; ?></td>
- <td><a href="login.php">post</a> | <a href="login.php">artifact</a></td>
+ <td><a href="login.php?profile=post">post</a> | <a href="login.php?profile=artifact">artifact</a></td>
</tr>
<?php } else { ?>
<tr>
@@ -97,8 +110,8 @@ You can get more informations about <b>Lasso</b> at <br>
</table>
</p>
-<p>
-<table>
+<p align='center'>
+<table align='center'>
<caption><b>Status</b></caption>
<tr>
<?php
@@ -118,19 +131,14 @@ You can get more informations about <b>Lasso</b> at <br>
<td><b>UserID:</b></td><td><?php echo $_SESSION["user_id"]; ?></td>
</tr>
<?php
- $db = &DB::connect($config['dsn']);
-
- if (DB::isError($db))
- die($db->getMessage());
-
+
$query = "SELECT * FROM users WHERE user_id='". $_SESSION["user_id"] ."'";
$res =& $db->query($query);
if (DB::isError($res))
- print $res->getMessage(). "\n";
+ die($res->getMessage());
list($user_id, $identity_dump, $first_name, $last_name, $last_login, $created) = $res->fetchRow();
-
?>
<tr>
<td><b>Last Name:</b></td><td><?php echo $last_name; ?></td>
@@ -147,20 +155,16 @@ You can get more informations about <b>Lasso</b> at <br>
<tr>
<td><b>Last Login:</b></td><td><?php echo $last_login; ?></td>
<?php
- $db->disconnect();
}
?>
</tr>
</table>
</p>
-<!-- <p>Lasso Version : <?php // echo lasso_version(); ?></p> -->
-
<br>
-<p>Copyright &copy; 2004 Entr'ouvert</p>
-
+<p align='center'>Copyright &copy; 2004 Entr'ouvert</p>
</body>
-
</html>
<?php
lasso_shutdown();
- ?>
+ $db->disconnect();
+?>
diff --git a/php/Attic/examples/sample-sp/log_view.php b/php/Attic/examples/sample-sp/log_view.php
new file mode 100644
index 00000000..68acc458
--- /dev/null
+++ b/php/Attic/examples/sample-sp/log_view.php
@@ -0,0 +1,160 @@
+<?php
+/*
+ * Identity Provider Example -- View log
+ *
+ * Copyright (C) 2004 Entr'ouvert
+ * http://lasso.entrouvert.org
+ *
+ * Authors: Christophe Nowicki <cnowicki@easter-eggs.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+ require_once 'HTML/QuickForm.php';
+ require_once 'DB.php';
+
+ $config = unserialize(file_get_contents('config.inc'));
+
+ // connect to the data base
+ $db = &DB::connect($config['dsn']);
+ if (DB::isError($db))
+ die("Could not connect to the database");
+
+ if ($config['log_handler'] != 'sql')
+ die("Unsupported log handler");
+
+ $number_of_msg = 8;
+
+ // Count log messages
+ $query = "SELECT COUNT(*) FROM log";
+ $res =& $db->query($query);
+ if (DB::isError($res))
+ die($res->getMessage());
+
+ $row = $res->fetchRow();
+ $count = $row[0];
+
+ $startMsg = ((empty($_GET['startMsg'])) ? 0 : $_GET['startMsg']);
+
+ $query = "SELECT * FROM log ORDER BY id DESC";
+ if (!isset($_GET['show_all']))
+ $query .= " OFFSET $startMsg LIMIT " . ($startMsg + $number_of_msg);
+
+
+ $res =& $db->query($query);
+ if (DB::isError($res))
+ die($res->getMessage());
+
+ $numRows = $res->numRows();
+
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+<head>
+<head>
+ <title>Lasso Identity Provider Example : View Logs</title>
+</head>
+<body>
+<br>
+<table border='1' width='100%'>
+<caption>Logged events</caption>
+<thead>
+<tr>
+ <td colspan='4'>
+ <?php
+ if ($startMsg)
+ echo "<a href=$PHP_SELF?startMsg=" . ($startMsg - $number_of_msg) . ">Previous</a>";
+ else
+ echo "Previous"
+ ?>
+ |
+ <?php
+ if ((($count - $startMsg) > $number_of_users) && !isset($_GET['show_all']))
+ echo "<a href=\"" . $PHP_SELF . "?startMsg=" . ($startMsg + $number_of_msg) . "\">Next</a>";
+ else
+ echo "Next";
+
+ if (isset($_GET['show_all']))
+ echo "| <a href=\"" . $PHP_SELF ."?startMsg=0\">Paginate</a>";
+ else
+ {
+ for ($i = 0; $i < $count; $i += $number_of_msg)
+ if ($i == $startMsg)
+ echo "| " . ( $i / $number_of_msg);
+ else
+ echo "| <a href=\"$PHP_SELF?startMsg=$i\">" . ( $i / $number_of_msg) . "</a>";
+ if ($count > $number_of_msg)
+ echo "| <a href=\"$PHP_SELF?show_all=1\">Show All</a>";
+ }
+ ?>
+ </td>
+</tr>
+<tr>
+ <td align='center'>date</td>
+ <td align='center'>filename</td>
+ <td align='center'>priority</td>
+ <td align='center'>message</td>
+</tr>
+</thead>
+<tbody>
+<?php
+ if ($numRows)
+ {
+ $num_col = $res->numCols();
+ $tableinfo = $db->tableInfo($res);
+
+ $desc = array("emergency", "alert", "critical", "error", "warning", "notice", "informational", "debug");
+
+ while($row = $res->fetchRow())
+ {
+ echo "<tr>";
+ for ($i = 0; $i < $num_col; $i++)
+ {
+ switch ($tableinfo[$i]['name'])
+ {
+ case "id":
+ break;
+ case "priority":
+ echo "<td align='center'>" . $desc[$row[$i]] . "</td>";
+ break;
+ case "message":
+ echo "<td>" . $row[$i] . "</td>";
+ break;
+ default:
+ echo "<td align='center'>" . $row[$i] . "</td>";
+ }
+ }
+ echo "</tr>";
+ }
+ }
+?>
+<tr>
+</tr>
+</tbody>
+<tfoot>
+<tr>
+ <td colspan='4'>&nbsp;</td>
+</tr>
+</tfoot>
+</table>
+<br>
+<p align='center'><a href='index.php'>Index</a>
+</p>
+<br>
+<p>Copyright &copy; 2004 Entr'ouvert</p>
+</body>
+</html>
+
diff --git a/php/Attic/examples/sample-sp/login.php b/php/Attic/examples/sample-sp/login.php
index 229aa28a..c857e5cd 100644
--- a/php/Attic/examples/sample-sp/login.php
+++ b/php/Attic/examples/sample-sp/login.php
@@ -1,6 +1,5 @@
<?php
/*
- *
* Service Provider Example -- Simple Sing On
*
* Copyright (C) 2004 Entr'ouvert
@@ -22,10 +21,14 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
+
+ require_once 'Log.php';
+ require_once 'DB.php';
$config = unserialize(file_get_contents('config.inc'));
+ session_start();
+
lasso_init();
$server_dump = file_get_contents($config['server_dump_filename']);
@@ -34,20 +37,29 @@
$login = new LassoLogin($server);
- $login->initauthnrequest(lassoHttpMethodRedirect);
-
- $request = $login->authnRequest;
+ switch($_GET['profile'])
+ {
+ case 'post':
+ // TODO
+ break;
+ case 'artifact':
+ $login->initauthnrequest(lassoHttpMethodRedirect);
+
+ $request = $login->authnRequest;
- $request->isPassive = FALSE;
- $request->nameIdPolicy = lassoLibNameIDPolicyTypeFederated;
- $request->consent = lassoLibConsentObtained;
+ $request->isPassive = FALSE;
+ $request->nameIdPolicy = lassoLibNameIDPolicyTypeFederated;
+ $request->consent = lassoLibConsentObtained;
- $login->buildAuthnRequestMsg($config['providerID']);
+ $login->buildAuthnRequestMsg($config['providerID']);
- $url = $login->msgUrl;
+ $url = $login->msgUrl;
- header("Request-URI: $url");
- header("Content-Location: $url");
- header("Location: $url\r\n\r\n");
- exit();
+ header("Request-URI: $url");
+ header("Content-Location: $url");
+ header("Location: $url\r\n\r\n");
+ exit();
+ default:
+ die('Unknown single sign on profile');
+ }
?>
diff --git a/php/Attic/examples/sample-sp/logout.php b/php/Attic/examples/sample-sp/logout.php
index 81937679..68f15fea 100644
--- a/php/Attic/examples/sample-sp/logout.php
+++ b/php/Attic/examples/sample-sp/logout.php
@@ -69,7 +69,6 @@
$url['path'], $url['host'], $url['port'],
strlen($logout->msgBody), $logout->msgBody);
- die($soap);
# PHP 4.3.0 with OpenSSL support required
$fp = fsockopen("ssl://" . $url['host'], $url['port'], $errno, $errstr, 30) or die($errstr ($errno));
diff --git a/php/Attic/examples/sample-sp/metadata_idp1.xml b/php/Attic/examples/sample-sp/metadata_idp1.xml
index 3330c73d..5dda1a22 100644
--- a/php/Attic/examples/sample-sp/metadata_idp1.xml
+++ b/php/Attic/examples/sample-sp/metadata_idp1.xml
@@ -4,16 +4,16 @@
xmlns="urn:liberty:metadata:2003-08">
<IDPDescriptor>
- <SingleSignOnServiceURL>https://idp1:1998/singleSignOn</SingleSignOnServiceURL>
+ <SingleSignOnServiceURL>https://idp1:1998/singleSignOn.php</SingleSignOnServiceURL>
<SingleSignOnProtocolProfile>http://projectliberty.org/profiles/sso-get</SingleSignOnProtocolProfile>
- <SingleLogoutServiceURL>https://idp1:1998/singleLogout</SingleLogoutServiceURL>
+ <SingleLogoutServiceURL>https://idp1:1998/singleLogout.php</SingleLogoutServiceURL>
<SingleLogoutProtocolProfile>http://projectliberty.org/profiles/slo-idp-soap</SingleLogoutProtocolProfile>
- <RegisterNameIdentifierServiceURL>https://idp1:1998/registerNameIdentifier</RegisterNameIdentifierServiceURL>
+ <RegisterNameIdentifierServiceURL>https://idp1:1998/registerNameIdentifier.php</RegisterNameIdentifierServiceURL>
<RegisterNameIdentifierProtocolProfile>http://projectliberty.org/profiles/rni-sp-http</RegisterNameIdentifierProtocolProfile>
- <SoapEndpoint>https://idp1:1998/soapEndpoint</SoapEndpoint>
+ <SoapEndpoint>https://idp1:1998/soapEndpoint.php</SoapEndpoint>
</IDPDescriptor>
</EntityDescriptor>
diff --git a/php/Attic/examples/sample-sp/setup.php b/php/Attic/examples/sample-sp/setup.php
index eebd81ed..c6c44228 100644
--- a/php/Attic/examples/sample-sp/setup.php
+++ b/php/Attic/examples/sample-sp/setup.php
@@ -22,8 +22,10 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+ require_once 'DB.php';
?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?php
if(!extension_loaded('lasso')) {
$ret = @dl('lasso.' . PHP_SHLIB_SUFFIX);
@@ -35,9 +37,8 @@
print "<a href='http://lasso.entrouvert.org/'>http://lasso.entrouvert.org/</a></p>";
exit();
}
- }
+ }
- require_once 'DB.php';
# default config
if (!file_exists('config.inc'))
@@ -46,6 +47,7 @@
$config = array(
'dsn' => "pgsql://sp:sp@localhost/sp",
'server_dump_filename' => "lasso_server_dump.xml",
+ 'log_handler' => "sql",
'sp-metadata' => $cwd . "/metadata_sp1.xml",
'sp-public_key' => $cwd . "/public-key_sp1.pem",
'sp-private_key' => $cwd . "/private-key-raw_sp1.pem",
@@ -140,7 +142,41 @@
die($res->getMessage());
print "OK";
+
+ print "<br>Create table 'log' : ";
+ $query = "DROP TABLE log CASCADE";
+ $res =& $db->query($query);
+
+ $query = "CREATE TABLE log (
+ id integer primary key,
+ logtime timestamp,
+ ident varchar(16),
+ priority integer,
+ message text)";
+
+ $res =& $db->query($query);
+ if (DB::isError($res))
+ die($res->getMessage());
+
+ print "OK";
+
+
+ print "<br>Create table 'sessions' : ";
+ $query = "DROP TABLE sessions CASCADE";
+ $res =& $db->query($query);
+
+ $query = "CREATE TABLE sessions (
+ id varchar(32) primary key,
+ expiry integer,
+ data text
+ )";
+ $res =& $db->query($query);
+ if (DB::isError($res))
+ die($res->getMessage());
+
+ print "OK";
+
$db->disconnect();
$keys = array_keys($config);
@@ -151,9 +187,7 @@
{
print "<br>Check file " . $config[$file] . " : ";
if (!file_exists($config[$file]))
- {
die("Failed (file does not exist)");
- }
else
print "OK";
}
@@ -262,6 +296,20 @@
</tr>
<tr>
+ <td colspan='3' align='center'>Logging</td>
+</tr>
+<tr>
+ <td>Handler :</td>
+ <td>
+ <select name='log_handler'>
+ <option value="null" <?php if ($config['log_handler'] == 'null') echo 'selected="selected"'; ?>>NULL (disabled)</option>
+ <option value="sql" <?php if ($config['log_handler'] == 'sql') echo 'selected="selected"'; ?>>Database</option>
+ <option value="syslog" <?php if ($config['log_handler'] == 'syslog') echo 'selected="selected"'; ?>>Syslog</option>
+ </select>
+ </td><td>&nbsp;</td>
+</tr>
+
+<tr>
<td colspan='3' align='center'>Service Provider</td>
</tr>
diff --git a/php/Attic/examples/sample-sp/view_session.php b/php/Attic/examples/sample-sp/view_session.php
new file mode 100644
index 00000000..3a8252b3
--- /dev/null
+++ b/php/Attic/examples/sample-sp/view_session.php
@@ -0,0 +1,88 @@
+<?php
+/*
+ * Service Provider Example -- Online User Viewer
+ *
+ * Copyright (C) 2004 Entr'ouvert
+ * http://lasso.entrouvert.org
+ *
+ * Authors: Christophe Nowicki <cnowicki@easter-eggs.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+ require_once 'DB.php';
+
+ if (!file_exists('config.inc'))
+ {
+?>
+<p align='center'><b>Service Provider Configuration file is not available</b><br>
+Please run the setup script :<br>
+<a href='setup.php'>Lasso Service Provider Setup</a><br>
+You can get more informations about <b>Lasso</b> at <br>
+<a href='http://lasso.entrouvert.org/'>http://lasso.entrouvert.org/</a></p>
+<?php
+ exit();
+ }
+ $config = unserialize(file_get_contents('config.inc'));
+
+ $db = &DB::connect($config['dsn']);
+
+ if (DB::isError($db))
+ die($db->getMessage());
+
+ $query = "SELECT * FROM sessions";
+
+ $res =& $db->query($query);
+ if (DB::isError($res))
+ die($res->getMessage());
+
+ $numRows = $res->numRows();
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+<head>
+<title>Lasso Service Provider Example : View Online Users</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />
+</head>
+<body>
+
+<p align='center'>
+<table align='center' width='95%'>
+<caption>Online Users</caption>
+<thead>
+<tr>
+ <td>&nbsp;</td>
+</tr>
+</thead>
+<tbody>
+
+</tbody>
+<tfoot>
+<tr>
+ <td>&nbsp;</td>
+</tr>
+</tfoot>
+</table>
+</p>
+
+<br>
+<p align='center'><a href='index.php'>Index</a>
+</p>
+<br>
+<p align='center'>Copyright &copy; 2004 Entr'ouvert</p>
+
+</body>
+</html>