Loading classes/login/TestLogin.php 0 → 100644 +34 −0 Original line number Diff line number Diff line <?php namespace RAP; class TestLogin extends LoginHandler { private $fakeIdentities = []; public function __construct(Locator $locator) { parent::__construct($locator); // Create fake identities $this->fakeIdentities[1] = $this->getFakeIdentity(Identity::EDU_GAIN, 1); $this->fakeIdentities[2] = $this->getFakeIdentity(Identity::GOOGLE, 2); $this->fakeIdentities[3] = $this->getFakeIdentity(Identity::LINKEDIN, 3); } public function login(): string { return $this->locator->getBasePath() . '/auth/test/select'; } public function retrieveToken(int $id): string { return $this->onIdentityDataReceived($this->fakeIdentities[$id]); } private function getFakeIdentity(string $type, int $i): Identity { $identity = new Identity($type); $identity->email = 'fake-user' . $i . "@example.com"; $identity->eppn = $identity->email; $identity->typedId = 'fake-user' . $i; return $identity; } } classes/model/AuthPageModel.php +4 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ class AuthPageModel { public $facebook; public $linkedIn; public $localIdP; public $test; // public $clientIcon; public $clientTitle; Loading Loading @@ -58,6 +59,9 @@ class AuthPageModel { $this->localIdP = isset($config->authenticationMethods->LocalIdP) && in_array(AuthenticationMethods::LOCAL_IDP, $client->authMethods); $this->test = isset($config->authenticationMethods->test) && $config->authenticationMethods->test; } } include/front-controller.php +22 −0 Original line number Diff line number Diff line Loading @@ -224,6 +224,28 @@ Flight::route('/auth/x509', function() { $x509Login->login(); }); Flight::route('GET /auth/test', function() { session_start(); global $locator; $testLogin = new \RAP\TestLogin($locator); Flight::redirect($testLogin->login()); }); Flight::route('GET /auth/test/select', function() { global $locator; Flight::render('test-login.php', array('title' => 'Test login (demo)', 'version' => $locator->getVersion(), 'contextRoot' => $locator->config->contextRoot)); }); Flight::route('POST /auth/test/token', function() { session_start(); global $locator; $testLogin = new \RAP\TestLogin($locator); $id = filter_input(INPUT_POST, 'user_id', FILTER_SANITIZE_NUMBER_INT); Flight::redirect($testLogin->retrieveToken($id)); }); Flight::route('/local', function() { global $locator; Flight::redirect($locator->config->authenticationMethods->LocalIdP->url); Loading views/main-page.php +10 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,16 @@ include 'include/header.php'; <?php echo $model->localIdPConfig->description; ?> </div> <?php } ?> <?php if ($model->test) { ?> <div class="home-box"> <div class="img-wrapper"> <a href="auth/test"> <strong>Test Login</strong> </a> </div> Use fake accounts </div> <?php } ?> </div> </div> Loading views/test-login.php 0 → 100644 +22 −0 Original line number Diff line number Diff line <?php include 'include/header.php'; ?> <script src="js/index.js?v=<?php echo $version; ?>"></script> <h2 class="text-center">Test login</h2> <form class="col-xs-6 col-xs-offset-3" method="POST" action="<?php echo $contextRoot . '/auth/test/token'; ?>"> <p>Select fake user:</p> <select class="form-control" name="user_id"> <option value="1">Fake User 1 (eduGAIN)</option> <option value="2">Fake User 2 (Google)</option> <option value="3">Fake User 3 (LinkedIn)</option> </select> <br/> <input type="submit" value="Login" class="btn btn-success" /> <br/><br/> </form> <?php include 'include/footer.php'; Loading
classes/login/TestLogin.php 0 → 100644 +34 −0 Original line number Diff line number Diff line <?php namespace RAP; class TestLogin extends LoginHandler { private $fakeIdentities = []; public function __construct(Locator $locator) { parent::__construct($locator); // Create fake identities $this->fakeIdentities[1] = $this->getFakeIdentity(Identity::EDU_GAIN, 1); $this->fakeIdentities[2] = $this->getFakeIdentity(Identity::GOOGLE, 2); $this->fakeIdentities[3] = $this->getFakeIdentity(Identity::LINKEDIN, 3); } public function login(): string { return $this->locator->getBasePath() . '/auth/test/select'; } public function retrieveToken(int $id): string { return $this->onIdentityDataReceived($this->fakeIdentities[$id]); } private function getFakeIdentity(string $type, int $i): Identity { $identity = new Identity($type); $identity->email = 'fake-user' . $i . "@example.com"; $identity->eppn = $identity->email; $identity->typedId = 'fake-user' . $i; return $identity; } }
classes/model/AuthPageModel.php +4 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ class AuthPageModel { public $facebook; public $linkedIn; public $localIdP; public $test; // public $clientIcon; public $clientTitle; Loading Loading @@ -58,6 +59,9 @@ class AuthPageModel { $this->localIdP = isset($config->authenticationMethods->LocalIdP) && in_array(AuthenticationMethods::LOCAL_IDP, $client->authMethods); $this->test = isset($config->authenticationMethods->test) && $config->authenticationMethods->test; } }
include/front-controller.php +22 −0 Original line number Diff line number Diff line Loading @@ -224,6 +224,28 @@ Flight::route('/auth/x509', function() { $x509Login->login(); }); Flight::route('GET /auth/test', function() { session_start(); global $locator; $testLogin = new \RAP\TestLogin($locator); Flight::redirect($testLogin->login()); }); Flight::route('GET /auth/test/select', function() { global $locator; Flight::render('test-login.php', array('title' => 'Test login (demo)', 'version' => $locator->getVersion(), 'contextRoot' => $locator->config->contextRoot)); }); Flight::route('POST /auth/test/token', function() { session_start(); global $locator; $testLogin = new \RAP\TestLogin($locator); $id = filter_input(INPUT_POST, 'user_id', FILTER_SANITIZE_NUMBER_INT); Flight::redirect($testLogin->retrieveToken($id)); }); Flight::route('/local', function() { global $locator; Flight::redirect($locator->config->authenticationMethods->LocalIdP->url); Loading
views/main-page.php +10 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,16 @@ include 'include/header.php'; <?php echo $model->localIdPConfig->description; ?> </div> <?php } ?> <?php if ($model->test) { ?> <div class="home-box"> <div class="img-wrapper"> <a href="auth/test"> <strong>Test Login</strong> </a> </div> Use fake accounts </div> <?php } ?> </div> </div> Loading
views/test-login.php 0 → 100644 +22 −0 Original line number Diff line number Diff line <?php include 'include/header.php'; ?> <script src="js/index.js?v=<?php echo $version; ?>"></script> <h2 class="text-center">Test login</h2> <form class="col-xs-6 col-xs-offset-3" method="POST" action="<?php echo $contextRoot . '/auth/test/token'; ?>"> <p>Select fake user:</p> <select class="form-control" name="user_id"> <option value="1">Fake User 1 (eduGAIN)</option> <option value="2">Fake User 2 (Google)</option> <option value="3">Fake User 3 (LinkedIn)</option> </select> <br/> <input type="submit" value="Login" class="btn btn-success" /> <br/><br/> </form> <?php include 'include/footer.php';