Skip to content
Snippets Groups Projects
Commit d56cd5bf authored by Olav Morken's avatar Olav Morken
Browse files

Add autotest module.

This module provides some webpages that can be used to test
authentication sources.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1827 44740490-163a-0410-bde0-09ae8108e29a
parent dfd99660
No related branches found
No related tags found
No related merge requests found
This file indicates that the default state of this module
is disabled. To enable, create a file named enable in the
same directory as this file.
`autotest` module
=================
This module provides an interface to do automatic testing of authentication sources.
To enable it, create a file named "enable" in modules/autotest.
It provides three webpages:
- https://.../simplesaml/module.php/autotest/login.php
- https://.../simplesaml/module.php/autotest/logout.php
- https://.../simplesaml/module.php/autotest/attributes.php
All the webpages have a mandatory paremeter 'SourceID', which is the name of the authentication source.
On success, the web pages print a single line with "OK".
The attributes page will also list all the attributes of the user.
On error they set the HTTP status code to 500 Internal Server Error, print a line with "ERROR" and then any information about the error.
Note that you still have to parse the login pages to extract the parameters in the login form.
<?php
try {
if (!isset($_GET['SourceID'])) {
throw new SimpleSAML_Error_BadRequest('Missing SourceID parameter');
}
$sourceId = $_GET['SourceID'];
$as = new SimpleSAML_Auth_Simple($sourceId);
if (!$as->isAuthenticated()) {
throw new SimpleSAML_Error_Exception('Not authenticated.');
}
$attributes = $as->getAttributes();
header('Content-Type: text/plain; charset=utf-8');
echo("OK\n");
foreach ($attributes as $name => $values) {
echo("$name\n");
foreach ($values as $value) {
echo("\t$value\n");
}
}
} catch (Exception $e) {
header('HTTP/1.0 500 Internal Server Error');
header('Content-Type: text/plain; charset=utf-8');
echo("ERROR\n");
echo($e->getMessage() . "\n");
}
<?php
try {
if (!isset($_GET['SourceID'])) {
throw new SimpleSAML_Error_BadRequest('Missing SourceID parameter');
}
$sourceId = $_GET['SourceID'];
$as = new SimpleSAML_Auth_Simple($sourceId);
$as->requireAuth();
header('Content-Type: text/plain; charset=utf-8');
echo("OK\n");
} catch (Exception $e) {
header('HTTP/1.0 500 Internal Server Error');
header('Content-Type: text/plain; charset=utf-8');
echo("ERROR\n");
echo($e->getMessage() . "\n");
}
<?php
try {
if (!isset($_GET['SourceID'])) {
throw new SimpleSAML_Error_BadRequest('Missing SourceID parameter');
}
$sourceId = $_GET['SourceID'];
$as = new SimpleSAML_Auth_Simple($sourceId);
if ($as->isAuthenticated()) {
$as->logout();
}
header('Content-Type: text/plain; charset=utf-8');
echo("OK\n");
} catch (Exception $e) {
header('HTTP/1.0 500 Internal Server Error');
header('Content-Type: text/plain; charset=utf-8');
echo("ERROR\n");
echo($e->getMessage() . "\n");
}
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