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

Adding support for adding links to login page in authsources.php

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2228 44740490-163a-0410-bde0-09ae8108e29a
parent 7da29db3
Branches
Tags
No related merge requests found
...@@ -32,6 +32,12 @@ abstract class sspmod_core_Auth_UserPassBase extends SimpleSAML_Auth_Source { ...@@ -32,6 +32,12 @@ abstract class sspmod_core_Auth_UserPassBase extends SimpleSAML_Auth_Source {
* If this is NULL, we won't force any username. * If this is NULL, we won't force any username.
*/ */
private $forcedUsername; private $forcedUsername;
/**
* Links to pages from login page.
* From configuration
*/
protected $loginLinks;
/** /**
...@@ -46,6 +52,10 @@ abstract class sspmod_core_Auth_UserPassBase extends SimpleSAML_Auth_Source { ...@@ -46,6 +52,10 @@ abstract class sspmod_core_Auth_UserPassBase extends SimpleSAML_Auth_Source {
public function __construct($info, &$config) { public function __construct($info, &$config) {
assert('is_array($info)'); assert('is_array($info)');
assert('is_array($config)'); assert('is_array($config)');
if (isset($config['core:loginpage_links'])) {
$this->loginLinks = $config['core:loginpage_links'];
}
/* Call the parent constructor first, as required by the interface. */ /* Call the parent constructor first, as required by the interface. */
parent::__construct($info, $config); parent::__construct($info, $config);
...@@ -62,6 +72,13 @@ abstract class sspmod_core_Auth_UserPassBase extends SimpleSAML_Auth_Source { ...@@ -62,6 +72,13 @@ abstract class sspmod_core_Auth_UserPassBase extends SimpleSAML_Auth_Source {
$this->forcedUsername = $forcedUsername; $this->forcedUsername = $forcedUsername;
} }
/**
* Return login links from configuration
*/
public function getLoginLinks() {
return $this->loginLinks;
}
/** /**
* Initialize login. * Initialize login.
......
...@@ -93,6 +93,18 @@ foreach ($this->data['stateparams'] as $name => $value) { ...@@ -93,6 +93,18 @@ foreach ($this->data['stateparams'] as $name => $value) {
</form> </form>
<?php <?php
if(!empty($this->data['links'])) {
echo '<ul class="links" style="margin-top: 2em">';
foreach($this->data['links'] AS $l) {
echo '<li><a href="' . htmlspecialchars($l['href']) . '">' . htmlspecialchars($this->t($l['text'])) . '</a></li>';
}
echo '</ul>';
}
echo('<h2>' . $this->t('{login:help_header}') . '</h2>'); echo('<h2>' . $this->t('{login:help_header}') . '</h2>');
echo('<p>' . $this->t('{login:help_text}') . '</p>'); echo('<p>' . $this->t('{login:help_text}') . '</p>');
......
...@@ -18,6 +18,13 @@ $authStateId = $_REQUEST['AuthState']; ...@@ -18,6 +18,13 @@ $authStateId = $_REQUEST['AuthState'];
/* Retrieve the authentication state. */ /* Retrieve the authentication state. */
$state = SimpleSAML_Auth_State::loadState($authStateId, sspmod_core_Auth_UserPassBase::STAGEID); $state = SimpleSAML_Auth_State::loadState($authStateId, sspmod_core_Auth_UserPassBase::STAGEID);
$source = SimpleSAML_Auth_Source::getById($state[sspmod_core_Auth_UserPassBase::AUTHID]);
if ($source === NULL) {
throw new Exception('Could not find authentication source with id ' . $state[sspmod_core_Auth_UserPassBase::AUTHID]);
}
if (array_key_exists('username', $_REQUEST)) { if (array_key_exists('username', $_REQUEST)) {
$username = $_REQUEST['username']; $username = $_REQUEST['username'];
} elseif (isset($state['core:username'])) { } elseif (isset($state['core:username'])) {
...@@ -54,6 +61,7 @@ if (array_key_exists('forcedUsername', $state)) { ...@@ -54,6 +61,7 @@ if (array_key_exists('forcedUsername', $state)) {
$t->data['username'] = $username; $t->data['username'] = $username;
$t->data['forceUsername'] = FALSE; $t->data['forceUsername'] = FALSE;
} }
$t->data['links'] = $source->getLoginLinks();
$t->data['errorcode'] = $errorCode; $t->data['errorcode'] = $errorCode;
$t->show(); $t->show();
exit(); exit();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment