diff --git a/modules/customauth/lib/Auth/Source/StaticSource.php b/modules/customauth/lib/Auth/Source/StaticSource.php deleted file mode 100644 index faad9f056e9e77e5f4ffa86c863cbe2d7f7aec53..0000000000000000000000000000000000000000 --- a/modules/customauth/lib/Auth/Source/StaticSource.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace SimpleSAML\Module\customauth\Auth\Source; - -use SimpleSAML\Utils; - -/** - * Example authentication source. - * - * This class is an example authentication source which will always return a user with - * a static set of attributes. - * - * @author Olav Morken, UNINETT AS. - * @package SimpleSAMLphp - */ -class StaticSource extends \SimpleSAML\Auth\Source -{ - /** - * The attributes we return. - * @var array - */ - private $attributes; - - - /** - * Constructor for this authentication source. - * - * @param array $info Information about this authentication source. - * @param array $config Configuration. - */ - public function __construct($info, $config) - { - assert(is_array($info)); - assert(is_array($config)); - - // Call the parent constructor first, as required by the interface - parent::__construct($info, $config); - - // Parse attributes - try { - $this->attributes = Utils\Attributes::normalizeAttributesArray($config); - } catch (\Exception $e) { - throw new \Exception('Invalid attributes for authentication source ' . - $this->authId . ': ' . $e->getMessage()); - } - } - - - /** - * Log in using static attributes. - * - * @param array &$state Information about the current authentication. - * @return void - */ - public function authenticate(&$state) - { - assert(is_array($state)); - $state['Attributes'] = $this->attributes; - } -} diff --git a/modules/customauth/lib/Auth/Source/UserPass.php b/modules/customauth/lib/Auth/Source/UserPass.php deleted file mode 100644 index 1aa147b1c80303d5f3539f975ed5f1e3cb02da23..0000000000000000000000000000000000000000 --- a/modules/customauth/lib/Auth/Source/UserPass.php +++ /dev/null @@ -1,100 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace SimpleSAML\Module\customauth\Auth\Source; - -use SimpleSAML\Error; -use SimpleSAML\Utils; - -/** - * Example authentication source - username & password. - * - * This class is an example authentication source which stores all username/passwords in an array, - * and authenticates users against this array. - * - * @author Olav Morken, UNINETT AS. - * @package SimpleSAMLphp - */ - -class UserPass extends \SimpleSAML\Module\core\Auth\UserPassBase -{ - /** - * Our users, stored in an associative array. The key of the array is "<username>:<password>", - * while the value of each element is a new array with the attributes for each user. - * - * @var array - */ - private $users; - - - /** - * Constructor for this authentication source. - * - * @param array $info Information about this authentication source. - * @param array $config Configuration. - */ - public function __construct($info, $config) - { - assert(is_array($info)); - assert(is_array($config)); - - // Call the parent constructor first, as required by the interface - parent::__construct($info, $config); - - $this->users = []; - - // Validate and parse our configuration - foreach ($config as $userpass => $attributes) { - if (!is_string($userpass)) { - throw new \Exception( - 'Invalid <username>:<password> for authentication source ' . $this->authId . ': ' . $userpass - ); - } - - $userpass = explode(':', $userpass, 2); - if (count($userpass) !== 2) { - throw new \Exception( - 'Invalid <username>:<password> for authentication source ' . $this->authId . ': ' . $userpass[0] - ); - } - $username = $userpass[0]; - $password = $userpass[1]; - - try { - $attributes = Utils\Attributes::normalizeAttributesArray($attributes); - } catch (\Exception $e) { - throw new \Exception('Invalid attributes for user ' . $username . - ' in authentication source ' . $this->authId . ': ' . $e->getMessage()); - } - $this->users[$username . ':' . $password] = $attributes; - } - } - - - /** - * Attempt to log in using the given username and password. - * - * On a successful login, this function should return the users attributes. On failure, - * it should throw an exception. If the error was caused by the user entering the wrong - * username or password, a \SimpleSAML\Error\Error('WRONGUSERPASS') should be thrown. - * - * Note that both the username and the password are UTF-8 encoded. - * - * @param string $username The username the user wrote. - * @param string $password The password the user wrote. - * @return array Associative array with the users attributes. - */ - protected function login($username, $password) - { - assert(is_string($username)); - assert(is_string($password)); - - $userpass = $username . ':' . $password; - if (!array_key_exists($userpass, $this->users)) { - throw new Error\Error('WRONGUSERPASS'); - } - - return $this->users[$userpass]; - } -} diff --git a/modules/customauth/templates/authenticate.twig b/modules/customauth/templates/authenticate.twig deleted file mode 100644 index 6a2f52a718d800236f6574905bec428e8aec259d..0000000000000000000000000000000000000000 --- a/modules/customauth/templates/authenticate.twig +++ /dev/null @@ -1,29 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> - <title>customauth login page</title> - </head> - <body> - <h1>customauth login page</h1> - <p> - In this example you can log in with two accounts: <code>student</code> and <code>admin</code>. - In both cases, the password is the same as the username. - </p> - <form method="post" action="?"> - <p> - Username: - <input type="text" name="username"> - </p> - <p> - Password: - <input type="text" name="password"> - </p> - <input type="hidden" name="ReturnTo" value="{{ returnTo|escape('html') }}"> - <p><input type="submit" value="Log in"></p> - </form> -{% if badUserPass == true %} - <p>!!! Bad username or password !!!</p> -{% endif %} - </body> -</html> diff --git a/modules/customauth/www/redirecttest.php b/modules/customauth/www/redirecttest.php deleted file mode 100644 index eb333554d700153d8bca3296ca04a190062fc9a0..0000000000000000000000000000000000000000 --- a/modules/customauth/www/redirecttest.php +++ /dev/null @@ -1,19 +0,0 @@ -<?php - -/** - * Request handler for redirect filter test. - * - * @author Olav Morken, UNINETT AS. - * @package SimpleSAMLphp - */ - -if (!array_key_exists('StateId', $_REQUEST)) { - throw new \SimpleSAML\Error\BadRequest('Missing required StateId query parameter.'); -} - -/** @var array $state */ -$state = \SimpleSAML\Auth\State::loadState($_REQUEST['StateId'], 'customauth:redirectfilter-test'); - -$state['Attributes']['RedirectTest2'] = ['OK']; - -\SimpleSAML\Auth\ProcessingChain::resumeProcessing($state);