Skip to content
Snippets Groups Projects
Commit be06a740 authored by Tim van Dijen's avatar Tim van Dijen
Browse files

Assorted fixes

parent b871eb85
No related branches found
No related tags found
No related merge requests found
...@@ -15,14 +15,8 @@ if (!array_key_exists('AuthState', $_REQUEST)) { ...@@ -15,14 +15,8 @@ if (!array_key_exists('AuthState', $_REQUEST)) {
$authStateId = $_REQUEST['AuthState']; $authStateId = $_REQUEST['AuthState'];
if (array_key_exists('otp', $_REQUEST)) { if (array_key_exists('otp', $_REQUEST)) {
$otp = $_REQUEST['otp'];
} else {
$otp = '';
}
if (!empty($otp)) {
// attempt to log in // attempt to log in
$errorCode = \SimpleSAML\Module\authYubiKey\Auth\Source\YubiKey::handleLogin($authStateId, $otp); $errorCode = \SimpleSAML\Module\authYubiKey\Auth\Source\YubiKey::handleLogin($authStateId, $_REQUEST['otp']);
} else { } else {
$errorCode = null; $errorCode = null;
} }
......
This diff is collapsed.
...@@ -11,85 +11,87 @@ ...@@ -11,85 +11,87 @@
// Retrieve the authentication state // Retrieve the authentication state
if (!array_key_exists('AuthState', $_REQUEST)) { if (!array_key_exists('AuthState', $_REQUEST)) {
throw new \SimpleSAML\Error\BadRequest('Missing AuthState parameter.'); throw new \SimpleSAML\Error\BadRequest('Missing AuthState parameter.');
} }
$authStateId = $_REQUEST['AuthState']; $authStateId = $_REQUEST['AuthState'];
$state = \SimpleSAML\Auth\State::loadState($authStateId, \SimpleSAML\Module\core\Auth\UserPassBase::STAGEID); $state = \SimpleSAML\Auth\State::loadState($authStateId, \SimpleSAML\Module\core\Auth\UserPassBase::STAGEID);
$source = \SimpleSAML\Auth\Source::getById($state[\SimpleSAML\Module\core\Auth\UserPassBase::AUTHID]); $source = \SimpleSAML\Auth\Source::getById($state[\SimpleSAML\Module\core\Auth\UserPassBase::AUTHID]);
if ($source === NULL) { if ($source === null) {
throw new \Exception('Could not find authentication source with id ' . $state[\SimpleSAML\Module\core\Auth\UserPassBase::AUTHID]); throw new \Exception('Could not find authentication source with id '.$state[\SimpleSAML\Module\core\Auth\UserPassBase::AUTHID]);
} }
if (array_key_exists('username', $_REQUEST)) { if (array_key_exists('username', $_REQUEST)) {
$username = $_REQUEST['username']; $username = $_REQUEST['username'];
} elseif ($source->getRememberUsernameEnabled() && array_key_exists($source->getAuthId() . '-username', $_COOKIE)) { } elseif ($source->getRememberUsernameEnabled() && array_key_exists($source->getAuthId().'-username', $_COOKIE)) {
$username = $_COOKIE[$source->getAuthId() . '-username']; $username = $_COOKIE[$source->getAuthId().'-username'];
} elseif (isset($state['core:username'])) { } elseif (isset($state['core:username'])) {
$username = (string)$state['core:username']; $username = (string) $state['core:username'];
} else { } else {
$username = ''; $username = '';
} }
if (array_key_exists('password', $_REQUEST)) { if (array_key_exists('password', $_REQUEST)) {
$password = $_REQUEST['password']; $password = $_REQUEST['password'];
} else { } else {
$password = ''; $password = '';
} }
$errorCode = NULL; $errorCode = null;
$errorParams = NULL; $errorParams = null;
if (!empty($_REQUEST['username']) || !empty($password)) { if (!empty($_REQUEST['username']) || !empty($password)) {
// Either username or password set - attempt to log in // Either username or password set - attempt to log in
if (array_key_exists('forcedUsername', $state)) { if (array_key_exists('forcedUsername', $state)) {
$username = $state['forcedUsername']; $username = $state['forcedUsername'];
} }
if ($source->getRememberUsernameEnabled()) { if ($source->getRememberUsernameEnabled()) {
$sessionHandler = \SimpleSAML\SessionHandler::getSessionHandler(); $sessionHandler = \SimpleSAML\SessionHandler::getSessionHandler();
$params = $sessionHandler->getCookieParams(); $params = $sessionHandler->getCookieParams();
$params['expire'] = time(); $params['expire'] = time();
$params['expire'] += (isset($_REQUEST['remember_username']) && $_REQUEST['remember_username'] == 'Yes' ? 31536000 : -300); $params['expire'] += (isset($_REQUEST['remember_username']) && $_REQUEST['remember_username'] == 'Yes' ? 31536000 : -300);
\SimpleSAML\Utils\HTTP::setCookie($source->getAuthId() . '-username', $username, $params, FALSE); \SimpleSAML\Utils\HTTP::setCookie($source->getAuthId().'-username', $username, $params, false);
} }
if ($source->isRememberMeEnabled()) { if ($source->isRememberMeEnabled()) {
if (array_key_exists('remember_me', $_REQUEST) && $_REQUEST['remember_me'] === 'Yes') { if (array_key_exists('remember_me', $_REQUEST) && $_REQUEST['remember_me'] === 'Yes') {
$state['RememberMe'] = TRUE; $state['RememberMe'] = true;
$authStateId = \SimpleSAML\Auth\State::saveState($state, \SimpleSAML\Module\core\Auth\UserPassBase::STAGEID); $authStateId = \SimpleSAML\Auth\State::saveState($state, \SimpleSAML\Module\core\Auth\UserPassBase::STAGEID);
} }
} }
try { try {
\SimpleSAML\Module\core\Auth\UserPassBase::handleLogin($authStateId, $username, $password); \SimpleSAML\Module\core\Auth\UserPassBase::handleLogin($authStateId, $username, $password);
} catch (\SimpleSAML\Error\Error $e) { } catch (\SimpleSAML\Error\Error $e) {
/* Login failed. Extract error code and parameters, to display the error. */ /* Login failed. Extract error code and parameters, to display the error. */
$errorCode = $e->getErrorCode(); $errorCode = $e->getErrorCode();
$errorParams = $e->getParameters(); $errorParams = $e->getParameters();
} }
} }
$globalConfig = \SimpleSAML\Configuration::getInstance(); $globalConfig = \SimpleSAML\Configuration::getInstance();
$t = new \SimpleSAML\XHTML\Template($globalConfig, 'core:loginuserpass.php'); $t = new \SimpleSAML\XHTML\Template($globalConfig, 'core:loginuserpass.php');
$t->data['stateparams'] = array('AuthState' => $authStateId); $t->data['stateparams'] = array('AuthState' => $authStateId);
if (array_key_exists('forcedUsername', $state)) { if (array_key_exists('forcedUsername', $state)) {
$t->data['username'] = $state['forcedUsername']; $t->data['username'] = $state['forcedUsername'];
$t->data['forceUsername'] = TRUE; $t->data['forceUsername'] = true;
$t->data['rememberUsernameEnabled'] = FALSE; $t->data['rememberUsernameEnabled'] = false;
$t->data['rememberUsernameChecked'] = FALSE; $t->data['rememberUsernameChecked'] = false;
$t->data['rememberMeEnabled'] = $source->isRememberMeEnabled(); $t->data['rememberMeEnabled'] = $source->isRememberMeEnabled();
$t->data['rememberMeChecked'] = $source->isRememberMeChecked(); $t->data['rememberMeChecked'] = $source->isRememberMeChecked();
} else { } else {
$t->data['username'] = $username; $t->data['username'] = $username;
$t->data['forceUsername'] = FALSE; $t->data['forceUsername'] = false;
$t->data['rememberUsernameEnabled'] = $source->getRememberUsernameEnabled(); $t->data['rememberUsernameEnabled'] = $source->getRememberUsernameEnabled();
$t->data['rememberUsernameChecked'] = $source->getRememberUsernameChecked(); $t->data['rememberUsernameChecked'] = $source->getRememberUsernameChecked();
$t->data['rememberMeEnabled'] = $source->isRememberMeEnabled(); $t->data['rememberMeEnabled'] = $source->isRememberMeEnabled();
$t->data['rememberMeChecked'] = $source->isRememberMeChecked(); $t->data['rememberMeChecked'] = $source->isRememberMeChecked();
if (isset($_COOKIE[$source->getAuthId() . '-username'])) $t->data['rememberUsernameChecked'] = TRUE; if (isset($_COOKIE[$source->getAuthId().'-username'])) {
$t->data['rememberUsernameChecked'] = true;
}
} }
$t->data['links'] = $source->getLoginLinks(); $t->data['links'] = $source->getLoginLinks();
$t->data['errorcode'] = $errorCode; $t->data['errorcode'] = $errorCode;
...@@ -97,11 +99,10 @@ $t->data['errorcodes'] = SimpleSAML\Error\ErrorCodes::getAllErrorCodeMessages(); ...@@ -97,11 +99,10 @@ $t->data['errorcodes'] = SimpleSAML\Error\ErrorCodes::getAllErrorCodeMessages();
$t->data['errorparams'] = $errorParams; $t->data['errorparams'] = $errorParams;
if (isset($state['SPMetadata'])) { if (isset($state['SPMetadata'])) {
$t->data['SPMetadata'] = $state['SPMetadata']; $t->data['SPMetadata'] = $state['SPMetadata'];
} else { } else {
$t->data['SPMetadata'] = NULL; $t->data['SPMetadata'] = null;
} }
$t->show(); $t->show();
exit(); exit();
...@@ -52,7 +52,7 @@ if (array_key_exists('organization', $_REQUEST)) { ...@@ -52,7 +52,7 @@ if (array_key_exists('organization', $_REQUEST)) {
$errorCode = null; $errorCode = null;
$errorParams = null; $errorParams = null;
if ($organizations === null || !empty($organization)) { if ($organizations === null || !empty($organization)) {
if (!empty($username) && !empty($password)) { if (!empty($username) || !empty($password)) {
if ($source->getRememberUsernameEnabled()) { if ($source->getRememberUsernameEnabled()) {
$sessionHandler = \SimpleSAML\SessionHandler::getSessionHandler(); $sessionHandler = \SimpleSAML\SessionHandler::getSessionHandler();
......
...@@ -2,75 +2,72 @@ ...@@ -2,75 +2,72 @@
} }
.inlinesearch { .inlinesearch {
float: right; float: right;
margin: 0em 3px .5em 1em; margin: 0em 3px .5em 1em;
/* padding: .3em;*/ /* padding: .3em;*/
} }
.inlinesearch p { .inlinesearch p {
font-size: 94%; font-size: 94%;
color: #aaa; color: #aaa;
} }
.inlinesearch input { .inlinesearch input {
background-image:url('../../resources/icons/silk/magnifier.png'); background-image:url('../../resources/icons/silk/magnifier.png');
background-repeat:no-repeat; background-repeat:no-repeat;
background-position:center left; background-position:center left;
border: 1px solid #ccc; border: 1px solid #ccc;
padding: 2px 2px 2px 20px; padding: 2px 2px 2px 20px;
margin: 0px 2px 0px 0px; margin: 0px 2px 0px 0px;
} }
.inlinesearch * { .inlinesearch * {
margin: 0px; margin: 0px;
padding: 0px; padding: 0px;
} }
div.metalist { div.metalist {
clear: both; clear: both;
list-style: none; list-style: none;
margin: 1em 2px .5em 2px; margin: 1em 2px .5em 2px;
padding: 0px; padding: 0px;
} }
a.metaentry { a.metaentry {
display: block; display: block;
border: 1px solid #ccc; border: 1px solid #ccc;
margin: 0px 0px -1px 0px; margin: 0px 0px -1px 0px;
padding: .2em 1em .2em 20px; padding: .2em 1em .2em 20px;
cursor: pointer; cursor: pointer;
cursor: hand; cursor: hand;
} }
a.metaentry.favourite { a.metaentry.favourite {
background-image:url('../../resources/icons/silk/heart.png'); background-image:url('../../resources/icons/silk/heart.png');
background-repeat:no-repeat; background-repeat:no-repeat;
background-position:center left; background-position:center left;
} }
a.metaentry:hover { a.metaentry:hover {
border: 1px solid #ccc; border: 1px solid #ccc;
background: #eee; background: #eee;
background-image:url('../../resources/icons/silk/star.png');
background-image:url('../../resources/icons/silk/star.png'); background-repeat:no-repeat;
background-repeat:no-repeat; background-position:center left;
background-position:center left;
} }
a.metaentry img.entryicon { a.metaentry img.entryicon {
display: none; display: none;
} }
a.metaentry:hover img.entryicon { a.metaentry:hover img.entryicon {
display: inline; display: inline;
top: 0px; top: 0px;
bottom: 0px; bottom: 0px;
clear: both; clear: both;
float: right; float: right;
margin: 1em; margin: 1em;
padding: 3px; padding: 3px;
border: 1px solid #999; border: 1px solid #999;
} }
div.favourite { div.favourite {
margin: 1em 0px;
margin: 1em 0px; padding: 1em;
padding: 1em; border: 1px solid #ccc;
border: 1px solid #ccc; background-color: #eee;
background-color: #eee;
} }
<?php <?php
function tdate($input) { function tdate($input)
return date(DATE_RFC822, $input); {
return date(DATE_RFC822, $input);
} }
function hours($input) { function hours($input)
if ($input < 60) return number_format($input, 2) . ' sec'; {
if ($input < 60*60) return number_format(($input/60),2) . ' min'; if ($input < 60) {
if ($input < 24*60*60) return number_format(($input/(60*60)),2) . ' hours'; return number_format($input, 2).' sec';
return number_format($input/(24*60*60),2) . ' days'; }
if ($input < 60 * 60) {
return number_format(($input / 60), 2).' min';
}
if ($input < 24 * 60 * 60) {
return number_format(($input / (60 * 60)), 2).' hours';
}
return number_format($input / (24 * 60 * 60), 2).' days';
} }
function humanreadable($input) { function humanreadable($input)
$output = ""; {
$input = abs($input); $output = "";
$input = abs($input);
if ($input >= (1024*1024*1024*1024*1024*1024*1024*100)) { if ($input >= (1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 100)) {
$output = sprintf("%5ldEi", $input / (1024*1024*1024*1024*1024*1024) ); $output = sprintf("%5ldEi", $input / (1024 * 1024 * 1024 * 1024 * 1024 * 1024));
} else if ($input >= (1024*1024*1024*1024*1024*1024*10)) { } else if ($input >= (1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 10)) {
$output = sprintf("%5.1fEi", $input / (1024.0*1024.0*1024.0*1024.0*1024.0*1024.0) ); $output = sprintf("%5.1fEi", $input / (1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0));
} else if ($input >= (1024*1024*1024*1024*1024*1024)) { } else if ($input >= (1024 * 1024 * 1024 * 1024 * 1024 * 1024)) {
$output = sprintf("%5.2fEi", $input / (1024.0*1024.0*1024.0*1024.0*1024.0*1024.0) ); $output = sprintf("%5.2fEi", $input / (1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0));
} else if ($input >= (1024 * 1024 * 1024 * 1024 * 1024 * 100)) {
$output = sprintf("%5ldPi", $input / (1024 * 1024 * 1024 * 1024 * 1024));
} else if ($input >= (1024*1024*1024*1024*1024*100)) { } else if ($input >= (1024 * 1024 * 1024 * 1024 * 1024 * 10)) {
$output = sprintf("%5ldPi", $input / (1024*1024*1024*1024*1024) ); $output = sprintf("%5.1fPi", $input / (1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0));
} else if ($input >= (1024*1024*1024*1024*1024*10)) { } else if ($input >= (1024 * 1024 * 1024 * 1024 * 1024)) {
$output = sprintf("%5.1fPi", $input / (1024.0*1024.0*1024.0*1024.0*1024.0) ); $output = sprintf("%5.2fPi", $input / (1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0));
} else if ($input >= (1024*1024*1024*1024*1024)) { } else if ($input >= (1024 * 1024 * 1024 * 1024 * 100)) {
$output = sprintf("%5.2fPi", $input / (1024.0*1024.0*1024.0*1024.0*1024.0) ); $output = sprintf("%5ldTi", $input / (1024 * 1024 * 1024 * 1024));
} else if ($input >= (1024 * 1024 * 1024 * 1024 * 10)) {
} else if ($input >= (1024*1024*1024*1024*100)) { $output = sprintf("%5.1fTi", $input / (1024.0 * 1024.0 * 1024.0 * 1024.0));
$output = sprintf("%5ldTi", $input / (1024*1024*1024*1024) ); } else if ($input >= (1024 * 1024 * 1024 * 1024)) {
} else if ($input >= (1024*1024*1024*1024*10)) { $output = sprintf("%5.2fTi", $input / (1024.0 * 1024.0 * 1024.0 * 1024.0));
$output = sprintf("%5.1fTi", $input / (1024.0*1024.0*1024.0*1024.0) ); } else if ($input >= (1024 * 1024 * 1024 * 100)) {
} else if ($input >= (1024*1024*1024*1024)) { $output = sprintf("%5ldGi", $input / (1024 * 1024 * 1024));
$output = sprintf("%5.2fTi", $input / (1024.0*1024.0*1024.0*1024.0) ); } else if ($input >= (1024 * 1024 * 1024 * 10)) {
$output = sprintf("%5.1fGi", $input / (1024.0 * 1024.0 * 1024.0));
} else if ($input >= (1024 * 1024 * 1024)) {
} else if ($input >= (1024*1024*1024*100)) { $output = sprintf("%5.2fGi", $input / (1024.0 * 1024.0 * 1024.0));
$output = sprintf("%5ldGi", $input / (1024*1024*1024) ); } else if ($input >= (1024 * 1024 * 100)) {
} else if ($input >= (1024*1024*1024*10)) { $output = sprintf("%5ldMi", $input / (1024 * 1024));
$output = sprintf("%5.1fGi", $input / (1024.0*1024.0*1024.0) ); } else if ($input >= (1024 * 1024 * 10)) {
} else if ($input >= (1024*1024*1024)) { $output = sprintf("%5.1fM", $input / (1024.0 * 1024.0));
$output = sprintf("%5.2fGi", $input / (1024.0*1024.0*1024.0) ); } else if ($input >= (1024 * 1024)) {
$output = sprintf("%5.2fMi", $input / (1024.0 * 1024.0));
} else if ($input >= (1024*1024*100)) { } else if ($input >= (1024 * 100)) {
$output = sprintf("%5ldMi", $input / (1024*1024) ); $output = sprintf("%5ldKi", $input / 1024);
} else if ($input >= (1024*1024*10)) { } else if ($input >= (1024 * 10)) {
$output = sprintf("%5.1fM", $input / (1024.0*1024.0) ); $output = sprintf("%5.1fKi", $input / 1024.0);
} else if ($input >= (1024*1024)) { } else if ($input >= (1024)) {
$output = sprintf("%5.2fMi", $input / (1024.0*1024.0) ); $output = sprintf("%5.2fKi", $input / 1024.0);
} else {
} else if ($input >= (1024 * 100)) { $output = sprintf("%5ld", $input);
$output = sprintf("%5ldKi", $input / (1024) ); }
} else if ($input >= (1024 * 10)) {
$output = sprintf("%5.1fKi", $input / 1024.0 ); return $output;
} else if ($input >= (1024)) {
$output = sprintf("%5.2fKi", $input / 1024.0 );
} else {
$output = sprintf("%5ld", $input );
}
return $output;
} }
$config = \SimpleSAML\Configuration::getInstance(); $config = \SimpleSAML\Configuration::getInstance();
...@@ -73,26 +73,25 @@ $config = \SimpleSAML\Configuration::getInstance(); ...@@ -73,26 +73,25 @@ $config = \SimpleSAML\Configuration::getInstance();
\SimpleSAML\Utils\Auth::requireAdmin(); \SimpleSAML\Utils\Auth::requireAdmin();
$formats = array( $formats = array(
'bytes' => 'humanreadable', 'bytes' => 'humanreadable',
'bytes_read' => 'humanreadable', 'bytes_read' => 'humanreadable',
'bytes_written' => 'humanreadable', 'bytes_written' => 'humanreadable',
'limit_maxbytes' => 'humanreadable', 'limit_maxbytes' => 'humanreadable',
'time' => 'tdate', 'time' => 'tdate',
'uptime' => 'hours', 'uptime' => 'hours',
); );
$statsraw = \SimpleSAML\Memcache::getStats(); $statsraw = \SimpleSAML\Memcache::getStats();
$stats = $statsraw; $stats = $statsraw;
foreach($stats AS $key => &$entry) { foreach ($stats as $key => &$entry) {
if (array_key_exists($key, $formats)) { if (array_key_exists($key, $formats)) {
$func = $formats[$key]; $func = $formats[$key];
foreach($entry AS $k => $val) { foreach ($entry as $k => $val) {
$entry[$k] = $func($val); $entry[$k] = $func($val);
} }
} }
} }
$t = new \SimpleSAML\XHTML\Template($config, 'memcacheMonitor:memcachestat.tpl.php'); $t = new \SimpleSAML\XHTML\Template($config, 'memcacheMonitor:memcachestat.tpl.php');
......
...@@ -22,3 +22,4 @@ $config = array( ...@@ -22,3 +22,4 @@ $config = array(
'auth' => 'default-sp', 'auth' => 'default-sp',
'useridattr', 'user', 'useridattr', 'user',
); );
...@@ -31,3 +31,4 @@ function oauth_hook_cron(&$croninfo) ...@@ -31,3 +31,4 @@ function oauth_hook_cron(&$croninfo)
$croninfo['summary'][] = $message; $croninfo['summary'][] = $message;
} }
} }
...@@ -13,7 +13,7 @@ class Entity extends Base ...@@ -13,7 +13,7 @@ class Entity extends Base
foreach ($this->fields as $field) { foreach ($this->fields as $field) {
if (array_key_exists($field, $metadata)) { if (array_key_exists($field, $metadata)) {
if (array_key_exists('name', $metadata[$field])) { if (array_key_exists('name', $metadata[$field])) {
$translation[$field] = $this->template->t($metadata[$field]['name'], array(), false); $translation[$field] = $this->template->t($metadata[$field]['name']);
} }
} }
} }
......
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