Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • perun/perun-proxyidp/simplesamlphp-module-privacyidea
1 result
Show changes
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
use SimpleSAML\Module;
......@@ -15,11 +17,8 @@ if ($this->data['errorCode'] !== null) {
?>
<div class="error-dialog">
<img src="/<?php
echo htmlspecialchars(
$this->data['baseurlpath'],
ENT_QUOTES
); ?>resources/icons/experience/gtk-dialog-error.48x48.png"
<img src="/<?php echo htmlspecialchars($this->data['baseurlpath'], ENT_QUOTES);
?>resources/icons/experience/gtk-dialog-error.48x48.png"
class="float-l erroricon" alt="gtk-dialog-error"/>
<h2><?php echo $this->t('{login:error_header}'); ?></h2>
<p>
......@@ -46,7 +45,7 @@ if ($this->data['errorCode'] !== null) {
} elseif ($this->data['step'] < 2) {
echo '<h2>' . htmlspecialchars($this->t('{privacyidea:privacyidea:login_title}')) . '</h2>';
}
?>
?>
<form action="FormReceiver.php" method="POST" id="piLoginForm" name="piLoginForm" class="loginForm">
<div class="form-panel first valid" id="gaia_firstform">
......@@ -54,54 +53,58 @@ if ($this->data['errorCode'] !== null) {
<div class="input-wrapper focused">
<div class="identifier-shown">
<?php
if ($this->data['forceUsername']) {
if (!empty($this->data['username'])) {
?>
if ($this->data['forceUsername']) {
if (!empty($this->data['username'])) {
?>
<h3><?php echo htmlspecialchars($this->data['username']); ?></h3>
<?php
} ?>
<?php
} ?>
<input type="hidden" id="username" name="username"
value="<?php echo htmlspecialchars($this->data['username'] ?? '', ENT_QUOTES); ?>"/>
value="<?php
echo htmlspecialchars($this->data['username'] ?? '', ENT_QUOTES); ?>"/>
<?php
} elseif ($this->data['step'] <= 1) {
?>
} elseif ($this->data['step'] <= 1) {
?>
<p>
<label for="username" class="sr-only">
<?php echo $this->t('{login:username}'); ?>
</label>
<input type="text" id="username" tabindex="1" name="username" autofocus
value="<?php echo htmlspecialchars($this->data['username'], ENT_QUOTES); ?>"
placeholder="<?php echo htmlspecialchars($this->t('{login:username}'), ENT_QUOTES); ?>"
value="<?php
echo htmlspecialchars($this->data['username'], ENT_QUOTES); ?>"
placeholder="<?php
echo htmlspecialchars($this->t('{login:username}'), ENT_QUOTES); ?>"
/>
</p>
<?php
}
}
// Remember username in authproc
if (!$this->data['authProcFilterScenario']) {
if ($this->data['rememberUsernameEnabled'] || $this->data['rememberMeEnabled']) {
$rowspan = 1;
} elseif (array_key_exists('organizations', $this->data)) {
$rowspan = 3;
} else {
$rowspan = 2;
}
if ($this->data['rememberUsernameEnabled'] || $this->data['rememberMeEnabled']) {
if ($this->data['rememberUsernameEnabled']) {
echo str_repeat("\t", 4);
echo '<input type="checkbox" id="rememberUsername" tabindex="4" name="rememberUsername"
value="Yes" ';
echo $this->data['rememberUsernameChecked'] ? 'checked="Yes" /> ' : '/> ';
echo htmlspecialchars($this->t('{login:remember_username}'));
}
if ($this->data['rememberMeEnabled']) {
echo str_repeat("\t", 4);
echo '<input type="checkbox" id="rememberMe" tabindex="4" name="rememberMe" value="Yes" ';
echo $this->data['rememberMeChecked'] ? 'checked="Yes" /> ' : '/> ';
echo htmlspecialchars($this->t('{login:remember_me}'));
}
}
} ?>
if (!$this->data['authProcFilterScenario']) {
if ($this->data['rememberUsernameEnabled'] || $this->data['rememberMeEnabled']) {
$rowspan = 1;
} elseif (array_key_exists('organizations', $this->data)) {
$rowspan = 3;
} else {
$rowspan = 2;
}
if ($this->data['rememberUsernameEnabled'] || $this->data['rememberMeEnabled']) {
if ($this->data['rememberUsernameEnabled']) {
echo str_repeat("\t", 4);
echo '<input type="checkbox" id="rememberUsername" tabindex="4"'
. ' name="rememberUsername" value="Yes" ';
echo $this->data['rememberUsernameChecked'] ? 'checked="Yes" /> ' : '/> ';
echo htmlspecialchars($this->t('{login:remember_username}'));
}
if ($this->data['rememberMeEnabled']) {
echo str_repeat("\t", 4);
echo '<input type="checkbox" id="rememberMe" tabindex="4"'
. ' name="rememberMe" value="Yes" ';
echo $this->data['rememberMeChecked'] ? 'checked="Yes" /> ' : '/> ';
echo htmlspecialchars($this->t('{login:remember_me}'));
}
}
} ?>
<!-- Pass and OTP fields -->
<?php if (!$this->data['authProcFilterScenario']) { ?>
......@@ -109,21 +112,22 @@ if ($this->data['errorCode'] !== null) {
<?php echo $this->t('{privacyidea:privacyidea:password}'); ?>
</label>
<input id="password" name="password" tabindex="1" type="password" value="" class="text"
placeholder="<?php echo htmlspecialchars($this->data['passHint'], ENT_QUOTES); ?>"/>
placeholder="<?php
echo htmlspecialchars($this->data['passHint'], ENT_QUOTES); ?>"/>
<?php } ?>
<?php if ($this->data['step'] > 1) { ?>
<p id="message" role="alert"><?php
$messageOverride = $this->data['messageOverride'] ?? null;
if ($messageOverride === null || is_string($messageOverride)) {
echo htmlspecialchars(
$messageOverride ?? $this->data['message'] ?? '',
ENT_QUOTES
);
} elseif (is_callable($messageOverride)) {
echo call_user_func($messageOverride, $this->data['message'] ?? '');
}
?></p>
$messageOverride = $this->data['messageOverride'] ?? null;
if ($messageOverride === null || is_string($messageOverride)) {
echo htmlspecialchars(
$messageOverride ?? $this->data['message'] ?? '',
ENT_QUOTES
);
} elseif (is_callable($messageOverride)) {
echo call_user_func($messageOverride, $this->data['message'] ?? '');
}
?></p>
<?php } ?>
<?php if ($this->data['step'] > 1) { ?>
......@@ -131,7 +135,8 @@ if ($this->data['errorCode'] !== null) {
<label for="otp" class="sr-only">
<?php echo $this->t('{privacyidea:privacyidea:otp}'); ?>
</label>
<input id="otp" name="otp" type="password" placeholder="<?php echo htmlspecialchars($this->data['otpHint'], ENT_QUOTES); ?>"
<input id="otp" name="otp" type="password" placeholder="<?php
echo htmlspecialchars($this->data['otpHint'], ENT_QUOTES); ?>"
<?php if (($this->data['otpAvailable'] ?? true) && $this->data['noAlternatives']) {
echo ' autofocus';
} ?>>
......@@ -139,14 +144,16 @@ if ($this->data['errorCode'] !== null) {
<?php } ?>
<p>
<button id="submitButton" tabindex="1" class="rc-button rc-button-submit" type="submit" name="Submit" value="1">
<button id="submitButton" tabindex="1" class="rc-button rc-button-submit"
type="submit" name="Submit" value="1">
<?php echo htmlspecialchars($this->t('{login:login_button}'), ENT_QUOTES); ?>
</button>
</p>
<!-- Undefined index is suppressed and the default is used for these values -->
<input id="mode" type="hidden" name="mode" value="otp"
data-preferred="<?php echo htmlspecialchars($this->data['mode'], ENT_QUOTES); ?>"/>
data-preferred="<?php
echo htmlspecialchars($this->data['mode'], ENT_QUOTES); ?>"/>
<input id="pushAvailable" type="hidden" name="pushAvailable"
value="<?php echo ($this->data['pushAvailable'] ?? false) ? 'true' : ''; ?>"/>
......@@ -155,35 +162,45 @@ if ($this->data['errorCode'] !== null) {
value="<?php echo ($this->data['otpAvailable'] ?? true) ? 'true' : ''; ?>"/>
<input id="webAuthnSignRequest" type="hidden" name="webAuthnSignRequest"
value='<?php echo htmlspecialchars($this->data['webAuthnSignRequest'] ?? '', ENT_QUOTES); ?>'/>
value='<?php
echo htmlspecialchars($this->data['webAuthnSignRequest'] ?? '', ENT_QUOTES);
?>'/>
<input id="u2fSignRequest" type="hidden" name="u2fSignRequest"
value='<?php echo htmlspecialchars($this->data['u2fSignRequest'] ?? '', ENT_QUOTES); ?>'/>
value='<?php
echo htmlspecialchars($this->data['u2fSignRequest'] ?? '', ENT_QUOTES); ?>'/>
<input id="modeChanged" type="hidden" name="modeChanged" value=""/>
<input id="step" type="hidden" name="step"
value="<?php echo htmlspecialchars(strval(($this->data['step'] ?? null) ?: 2), ENT_QUOTES); ?>"/>
value="<?php
echo htmlspecialchars(strval(($this->data['step'] ?? null) ?: 2), ENT_QUOTES);
?>"/>
<input id="webAuthnSignResponse" type="hidden" name="webAuthnSignResponse" value=""/>
<input id="u2fSignResponse" type="hidden" name="u2fSignResponse" value=""/>
<input id="origin" type="hidden" name="origin" value=""/>
<input id="loadCounter" type="hidden" name="loadCounter"
value="<?php echo htmlspecialchars(strval(($this->data['loadCounter'] ?? null) ?: 1), ENT_QUOTES); ?>"/>
value="<?php
echo htmlspecialchars(
strval(($this->data['loadCounter'] ?? null) ?: 1),
ENT_QUOTES
); ?>"/>
<!-- Additional input to persist the message -->
<input type="hidden" name="message"
value="<?php echo htmlspecialchars($this->data['message'] ?? '', ENT_QUOTES); ?>"/>
value="<?php
echo htmlspecialchars($this->data['message'] ?? '', ENT_QUOTES); ?>"/>
<?php
// If enrollToken load QR Code
if (isset($this->data['tokenQR'])) {
echo htmlspecialchars($this->t('{privacyidea:privacyidea:scan_token_qr}')); ?>
if (isset($this->data['tokenQR'])) {
echo htmlspecialchars($this->t('{privacyidea:privacyidea:scan_token_qr}')); ?>
<div class="tokenQR">
<?php echo '<img src="' . $this->data['tokenQR'] . '" />'; ?>
</div>
<?php
}
?>
}
?>
</div>
<?php
......@@ -191,7 +208,8 @@ if ($this->data['errorCode'] !== null) {
if (array_key_exists('organizations', $this->data)) {
?>
<div class="identifier-shown">
<label for="organization"><?php echo htmlspecialchars($this->t('{login:organization}')); ?></label>
<label for="organization"><?php
echo htmlspecialchars($this->t('{login:organization}')); ?></label>
<select id="organization" name="organization" tabindex="3">
<?php
if (array_key_exists('selectedOrg', $this->data)) {
......@@ -200,25 +218,25 @@ if ($this->data['errorCode'] !== null) {
$selectedOrg = null;
}
foreach ($this->data['organizations'] as $orgId => $orgDesc) {
if (is_array($orgDesc)) {
$orgDesc = $this->t($orgDesc);
}
if ($orgId === $selectedOrg) {
$selected = 'selected="selected" ';
} else {
$selected = '';
}
echo '<option ' . $selected . 'value="' . htmlspecialchars(
$orgId,
ENT_QUOTES
) . '">' . htmlspecialchars($orgDesc) . '</option>';
} ?>
foreach ($this->data['organizations'] as $orgId => $orgDesc) {
if (is_array($orgDesc)) {
$orgDesc = $this->t($orgDesc);
}
if ($orgId === $selectedOrg) {
$selected = 'selected="selected" ';
} else {
$selected = '';
}
echo '<option ' . $selected . 'value="' . htmlspecialchars(
$orgId,
ENT_QUOTES
) . '">' . htmlspecialchars($orgDesc) . '</option>';
} ?>
</select>
</div>
<?php
<?php
} ?>
</div> <!-- focused -->
</div> <!-- slide-out-->
......@@ -256,7 +274,8 @@ if ($this->data['errorCode'] !== null) {
// Logout
if (($this->data['showLogout'] ?? true) && isset($this->data['LogoutURL'])) { ?>
<p>
<a href="<?php echo htmlspecialchars($this->data['LogoutURL']); ?>"><?php echo $this->t('{status:logout}'); ?></a>
<a href="<?php
echo htmlspecialchars($this->data['LogoutURL']); ?>"><?php echo $this->t('{status:logout}'); ?></a>
</p>
<?php } ?>
</div> <!-- End of login -->
......@@ -282,7 +301,8 @@ if (!empty($this->data['links'])) {
<meta id="privacyidea-step" name="privacyidea-step" content="<?php echo $this->data['step']; ?>">
<meta id="privacyidea-translations" name="privacyidea-translations" content="<?php echo htmlspecialchars(json_encode($this->data['translations'])); ?>">
<meta id="privacyidea-translations" name="privacyidea-translations" content="<?php
echo htmlspecialchars(json_encode($this->data['translations'])); ?>">
<script src="<?php echo htmlspecialchars(Module::getModuleUrl('privacyidea/js/loginform.js'), ENT_QUOTES); ?>">
</script>
......
......@@ -38,7 +38,10 @@ $tpl = new Template(Configuration::getInstance(), 'privacyidea:LoginForm.php');
$tpl->data['errorCode'] = null;
$tpl->data['errorMessage'] = null;
if (!empty($state['privacyidea:privacyidea']['errorCode']) || !empty($state['privacyidea:privacyidea']['errorMessage'])) {
if (
!empty($state['privacyidea:privacyidea']['errorCode'])
|| !empty($state['privacyidea:privacyidea']['errorMessage'])
) {
$tpl->data['errorCode'] = ($state['privacyidea:privacyidea']['errorCode'] ?? null) ?: '';
$state['privacyidea:privacyidea']['errorCode'] = '';
$tpl->data['errorMessage'] = $tpl->t('{privacyidea:privacyidea:error_message}');
......
......@@ -79,7 +79,8 @@ if ($state['privacyidea:privacyidea']['authenticationMethod'] === 'authprocess')
$params = $sessionHandler->getCookieParams();
$params['expire'] = time();
$params['expire'] += (isset($_REQUEST['rememberUsername']) && $_REQUEST['rememberUsername'] === 'Yes' ? 31536000 : -300);
$params['expire'] += (isset($_REQUEST['rememberUsername']) && $_REQUEST['rememberUsername'] === 'Yes'
? 31536000 : -300);
HTTP::setCookie($source->getAuthId() . '-username', $username, $params, false);
}
......