first commit

This commit is contained in:
2026-04-28 15:13:50 +02:00
commit a95acc355b
63745 changed files with 9487948 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
<?php login_header(); ?>
<form class="login-form">
<h3><?php echo esc_html__('Two-Factor Authentication', 'really-simple-ssl'); ?></h3>
<br>
<p>
<?php echo esc_html($message) ?>
</p>
</form>
<?php login_footer();

View File

@@ -0,0 +1,115 @@
<?php
login_header();
\RSSSL\Security\WordPress\Two_Fa\Rsssl_Two_Factor::maybe_show_last_login_failure_notice( $user );
if ( get_class($provider_class) === 'RSSSL\\Security\\WordPress\\Two_Fa\\Providers\\Rsssl_Two_Factor_Email' ) {
\RSSSL\Security\WordPress\Two_Fa\Providers\Rsssl_Two_Factor_Email::maybe_show_email_resend_notice( $user );
}
?>
<form name="rsssl_validate_2fa_form" id="loginform"
action="<?php echo esc_url( \RSSSL\Security\WordPress\Two_Fa\Rsssl_Two_Factor::login_url( array( 'action' => 'validate_2fa' ), 'login_post' ) ); ?>"
method="post" autocomplete="off">
<input type="hidden" name="provider" id="provider" value="<?php echo esc_attr( $provider_class::METHOD ); ?>"/>
<input type="hidden" name="rsssl-wp-auth-id" id="rsssl-wp-auth-id"
value="<?php echo esc_attr( $user->ID ); ?>"/>
<input type="hidden" name="rsssl-wp-auth-nonce" id="rsssl-wp-auth-nonce"
value="<?php echo esc_attr( $login_nonce ); ?>"/>
<?php if ( $interim_login ) { ?>
<input type="hidden" name="interim-login" value="1"/>
<?php } else { ?>
<input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>"/>
<?php } ?>
<input type="hidden" name="rememberme" id="rememberme" value="<?php echo esc_attr( $rememberme ); ?>"/>
<?php
$provider_class->authentication_page( $user );
?>
</form>
<?php
if ( get_class($provider_class) === 'RSSSL\Pro\Security\WordPress\Two_Fa\Rsssl_Two_Factor_Totp') {
?>
<div class="backup-methods-wrap">
<!-- <p class="backup-methods">-->
<!-- <a>-->
<!-- --><?php
// echo esc_html__('Or, enter your backup code.', 'really-simple-ssl');
// ?>
<!-- </a>-->
<!-- </p>-->
</div>
<?php
}
?>
<style>
/* @todo: migrate to an external stylesheet. */
.backup-methods-wrap {
margin-top: 16px;
padding: 0 24px;
}
.backup-methods-wrap a {
color: #999;
text-decoration: none;
}
ul.backup-methods {
display: none;
padding-left: 1.5em;
}
/* Prevent Jetpack from hiding our controls, see https://github.com/Automattic/jetpack/issues/3747 */
.jetpack-sso-form-display #loginform > p,
.jetpack-sso-form-display #loginform > div {
display: block;
}
#login form p.two-factor-prompt {
margin-bottom: 1em;
}
.input.rsssl-authcode {
letter-spacing: .3em;
}
.input.rsssl-authcode::placeholder {
opacity: 0.5;
}
</style>
<script>
(function () {
// Enforce numeric-only input for numeric inputmode elements.
const form = document.querySelector('#loginform'),
inputEl = document.querySelector('input.rsssl-authcode[inputmode="numeric"]'),
expectedLength = inputEl?.dataset.digits || 0;
if (inputEl) {
let spaceInserted = false;
inputEl.addEventListener(
'input',
function () {
let value = this.value.replace(/[^0-9 ]/g, '').trimStart();
if (!spaceInserted && expectedLength && value.length === Math.floor(expectedLength / 2)) {
value += ' ';
spaceInserted = true;
} else if (spaceInserted && !this.value) {
spaceInserted = false;
}
this.value = value;
// Auto-submit if it's the expected length.
if (expectedLength && value.replace(/ /g, '').length == expectedLength) {
if (undefined !== form.requestSubmit) {
form.requestSubmit();
form.submit.disabled = "disabled";
}
}
}
);
}
})();
</script>

View File

@@ -0,0 +1,173 @@
<?php
use RSSSL\Security\WordPress\Two_Fa\Providers\Rsssl_Two_Factor_Email;
use RSSSL\Pro\Security\WordPress\Two_Fa\Providers\Rsssl_Two_Factor_Totp;
/**
* @param $variable
* @param $default
*
* @return void
*/
function rsssl_check_and_set( &$variable, $default = null ) {
if ( ! isset( $variable ) ) {
$variable = $default;
}
}
// Use the function for all your variables
$variables_to_check = array(
'available_providers',
'selected_provider',
'rememberme',
'interim_login',
'nonce',
'login_nonce',
'action',
'redirect_to',
'url',
'minified_js',
'minified_css',
'interim_login',
'backup_providers',
'provider',
'primary_provider',
'$skip_two_fa_url',
'is_today'
);
foreach ( $variables_to_check as $var ) {
rsssl_check_and_set( $$var );
}
?>
<form id="two_fa_onboarding_form" class="login-form" method="post">
<h3><?php echo esc_html__( 'Two-Factor Authentication', 'really-simple-ssl' ); ?></h3>
<p class="rsssl_into_two_factor">
<?php
if ( $is_forced ) {
echo esc_html__(
'This site requires you to secure your account with a second authentication method.',
'really-simple-ssl'
);
} else {
echo sprintf( esc_html__(
'You can protect your account with a second authentication layer. Please choose one of the following methods, or click %s if you don\'t want to use Two-Factor Authentication.',
'really-simple-ssl'
), esc_html__( 'Don\'t ask again', 'really-simple-ssl' ) );
}
?>
</p>
<?php
if ( $is_forced && $grace_period ) {
?>
<br/>
<p>
<?php
if ( ! $is_today ) {
echo sprintf( esc_html__(
'Please make sure to configure a method, access to your account will be denied if no method is configured within the next %s days.',
'really-simple-ssl'
), $grace_period );
} else {
echo esc_html__( 'Please make sure to configure a method, access to your account will be denied if no method is configured today.', 'really-simple-ssl' );
}
?>
</p>
<?php
}
?>
<div id="rsssl_step_one_onboarding" class="rsssl_step_one_onboarding">
<?php
foreach ( $available_providers as $method => $provider ) {
$checked = $provider === $primary_provider;
$provider::get_selection_option( $user, $checked );
}
?>
</div>
<?php
if ( isset( $available_providers['totp'] ) ) {
?>
<div id="rsssl_step_two_onboarding" class="rsssl_step_two_onboarding">
<p>
<?php
try {
Rsssl_Two_Factor_Totp::display_onboarding_step_totp( $user );
} catch ( Exception $e ) {
wp_redirect( $redirect_to );
}
?>
</p>
</div>
<?php
}
if ( isset( $available_providers['passkey'] ) ) {
?>
<div id="rsssl_step_three_onboarding" class="rsssl_step_three_onboarding">
<p class="passkey-integration" id="passkey-integration">
</p>
</div>
<?php
}
if ( isset( $available_providers['email'] ) ) {
?>
<div id="rsssl_step_four_onboarding" class="rsssl_step_four_onboarding">
<p class="two-factor-prompt"><?php echo esc_html__( 'A verification code has been sent to the email address associated with your account.', 'really-simple-ssl' ); ?></p>
<p>
<label for="rsssl-authcode"><?php echo esc_html__( 'Verification Code:', 'really-simple-ssl' ); ?></label>
<input type="text" inputmode="numeric" name="rsssl-two-factor-email-code" id="rsssl-authcode"
class="input rsssl-authcode" value="" size="20" pattern="[0-9 ]*" placeholder="1234 5678"
data-digits="8"/>
</p>
<p class="rsssl-two-factor-email-resend">
<button type="button" class="button"
id="<?php echo esc_attr( Rsssl_Two_Factor_Email::RSSSL_INPUT_NAME_RESEND_CODE ); ?>"
name="<?php echo esc_attr( Rsssl_Two_Factor_Email::RSSSL_INPUT_NAME_RESEND_CODE ); ?>"><?php esc_attr_e( 'Resend Code', 'really-simple-ssl' ); ?></button>
</p>
</div>
<?php
}
?>
<p class="skip_container">
<?php
if ( ! $is_forced ) {
?>
<a href="#" id="do_not_ask_again">
<?php echo esc_html__( 'Don\'t ask again', 'really-simple-ssl' ); ?>
</a>
<a href="#" id="skip_onboarding">
<?php echo esc_html__( 'Skip', 'really-simple-ssl' ); ?>
</a>
<?php
} else {
// We check if there is a grace period.
if ( $grace_period ) {
?>
<a href="#" id="skip_onboarding">
<?php
if ( $is_today ) {
echo esc_html__( 'Skip (Only today remaining)', 'really-simple-ssl' );
} else {
echo sprintf(
esc_html__( 'Skip (%1$d %2$s remaining)', 'really-simple-ssl' ),
$grace_period,
$grace_period > 1 ? esc_html__( 'days', 'really-simple-ssl' ) : esc_html__( 'day', 'really-simple-ssl' )
);
}
?>
</a>
<?php
} else {
?>
<span></span>
<?php
}
}
?>
<input type="submit" id="rsssl_continue_onboarding" name="onboarding_submit"
class="button button-primary button-large"
value="<?php echo esc_html__( 'Continue', 'really-simple-ssl' ); ?>"/>
</p>
</form>

View File

@@ -0,0 +1,138 @@
<?php
/**
* This file contains the profile settings for the Two-Factor Authentication.
* It is used to display the Two-Factor Authentication settings on the user profile page.
* It also contains the logic to save the Two-Factor Authentication settings.
*
* @package really-simple-ssl-pro
* @since 4.0.0
*
*/
require_once rsssl_path . 'security/wordpress/two-fa/class-rsssl-two-factor-settings.php';
use RSSSL\Security\WordPress\Two_Fa\RSSSL_Passkey_List_Table;
use RSSSL\Security\WordPress\Two_Fa\Rsssl_Two_Factor_Settings;
?>
<br>
<p>
<h2><?php esc_html_e('Login protection', 'really-simple-ssl'); ?></h2>
<p><?php esc_html_e('Two-Factor Authentication adds an extra layer of security to your account. You can enable it here.', 'really-simple-ssl'); ?></p>
<?php if ($forced && !$one_enabled) : ?>
<p class="notice notice-warning">
<?php esc_html_e('Two-Factor Authentication is mandatory for your account, so you need to make a selection.', 'really-simple-ssl'); ?>
</p>
<?php endif; ?>
<table class="form-table rsssl-table-two-fa">
<!-- Two-Factor Authentication Selection -->
<tr>
<td colspan="2" style="padding-left:0">
<?php esc_html_e('Enable Two-Factor Authentication', 'really-simple-ssl'); ?>
<input type="hidden" name="two-factor-authentication" value="<?php echo $forced ?>" />
<input type="checkbox" style="padding-left:20px;" name="two-factor-authentication" id="two-factor-authentication"
value="1" <?php esc_html_e(checked($one_enabled || $forced));
esc_html_e(disabled($forced)) ?> />
</td>
</tr>
<!-- Two-Factor Authentication Selection -->
<?php if (!empty($backup_codes) && $one_enabled) : ?>
<tr>
<th scope="row">
<label for="two-factor-backup-codes"><?php esc_html_e('Backup Codes', 'really-simple-ssl'); ?></label>
</th>
<td>
<fieldset>
<legend class="screen-reader-text">
<span><?php esc_html_e('Backup Codes', 'really-simple-ssl'); ?></span>
</legend>
<!-- Displaying the download for the backup codes if Two-Factor Authentication is enabled -->
<a href="#"
id="download_codes"><?php esc_html_e('Download Backup Codes', 'really-simple-ssl'); ?></a>
<span class="rsssl-backup-codes warning"><?php esc_html_e('Codes only available for 5 minutes') ?></span>
</fieldset>
</td>
</tr>
<?php endif; ?>
<!-- Two-Factor Authentication Method Selection -->
<tr id="selection_two_fa">
<th scope="row">
<label for="two-factor-method"><?php echo esc_html__('Selected provider', 'really-simple-ssl'); ?></label>
</th>
<td>
<fieldset>
<legend class="screen-reader-text">
<span><?php esc_html_e('Preferred Method', 'really-simple-ssl'); ?></span>
</legend>
<?php foreach ($available_providers as $provider) : ?>
<?php // Skip passkey - it has its own dedicated section on the profile page. ?>
<?php if ( strtolower( $provider::METHOD ) === 'passkey' ) { continue; } ?>
<label for="two-factor-method-<?php echo esc_attr(get_class($provider)); ?>">
<input type="radio" name="preferred_method" class="preferred_method_selection" id="preferred_method_<?php echo $provider::METHOD ?>"
value="<?= esc_attr($provider::METHOD) ?>" <?php checked(strtolower($provider::METHOD) === strtolower(Rsssl_Two_Factor_Settings::get_login_action( $user_id ))); ?> />
<?= esc_html($provider::NAME) ?>
<br/>
<?php endforeach; ?>
</fieldset>
</td>
</tr>
<tr class="totp-config">
<td>
<div id="qr-code-container">
<p id="two-factor-qr-code">
<a href="<?= esc_url($totp_url) ?>">
Loading...
<img src="<?= esc_url(admin_url('images/spinner.gif')) ?>" alt=""/>
</a>
</p>
<p style="margin-bottom: 10px;">
<i id="totp-key">
<?php
echo esc_html(__('Copy setup key', 'really-simple-ssl'));
?>
</i>
</p>
<label for="two-factor-totp-authcode">
<strong><?php esc_html_e('Authentication Code:', 'really-simple-ssl'); ?></strong>
<?php
/* translators: Example auth code. */
$placeholder = sprintf(__('eg. %s', 'really-simple-ssl'), '123 456');
?>
<input type="tel" name="two-factor-totp-authcode" id="two-factor-totp-authcode" class="input"
value=""
size="20" pattern="[0-9 ]*" placeholder="<?= esc_attr($placeholder) ?>"/>
</label>
<!-- TOTP hidden fields -->
<input type="hidden" name="two-factor-totp-key" id="two-factor-totp-key"
value="<?= esc_attr($key) ?>"/>
<input type="hidden" name="two-factor-totp-url" id="two-factor-totp-url"
value="<?= esc_attr($totp_url) ?>"/>
</div>
</td>
</tr>
<tr id="rsssl_verify_email" class="rsssl_verify_email">
<td colspan="2">
<label for="rsssl-two-factor-email-code"><?php esc_html_e('Verification Code:', 'really-simple-ssl'); ?></label>
<input type="text" inputmode="numeric" name="rsssl-two-factor-email-code" id="rsssl-two-factor-email-code"
class="input rsssl-authcode" value="" size="20" pattern="[0-9 ]*" placeholder="1234 5678"
data-digits="8"/>
<p class="two-factor-prompt"><i><?php esc_html_e('A verification code has been sent to the email address associated with your account to verify functionality.', 'really-simple-ssl'); ?> <a href="#" id="rsssl_resend_code_action"> <?php esc_attr_e('Resend Code', 'really-simple-ssl'); ?></a></i></p>
</td>
</tr>
<tr id="rsssl_step_three_onboarding">
<td colspan="2">
<p class="passkey-integration" id="passkey-integration">
</p>
</td>
</tr>
<?php if ( $passkeys_enabled ) : ?>
<tr style="padding: 0;" id="passkey-table">
<td colspan="2" style="padding: 0;">
<?php RSSSL_Passkey_List_Table::display_table() ?>
</td>
</tr>
<?php endif; ?>
</table>

View File

@@ -0,0 +1,24 @@
<?php
if (!isset($user) || !$user instanceof WP_User) {
// We throw an error here because the $user variable is required
throw new RuntimeException('The $user variable is required.');
}
//checking all other variables
if (!isset($badge_class, $enabled_text, $checked_attribute, $title, $description, $type, $forcible)) {
return; // Return early if variables are not set
}
?>
<p>
<label class="radio-label">
<strong><?php echo $title ?></strong>
<input type="radio" name="preferred_method" value="<?php echo $type ?>"
class="radio-input" <?php echo $checked_attribute; ?>/>
</label>
<br>
<?php
echo $description;
// Get the user's role.
$user_roles = $user->roles;
// If this is in the forced roles, we do not show the "disable" link.
?>
</p>

View File

@@ -0,0 +1,54 @@
<?php
// Ensure the $user variable is available
if (!isset($user) || !$user instanceof WP_User) {
// We throw an error here because the $user variable is required
throw new RuntimeException('The $user variable is required.');
}
if (isset($_GET['error']) && $_GET['error'] === 1) {
?>
<p class="error">
<?php echo esc_html__('Authentication code is incorrect.', 'really-simple-ssl'); ?>
</p>
<?php
}
?>
<br/>
<p>
<strong><?php echo esc_html__('Install Authentication app:', 'really-simple-ssl'); ?></strong><br/>
<?php
printf(
// Translators: %s is the hyperlink for "Download"
esc_html__('Use your authenticator app like Google Authenticator to scan the QR code below, then paste the provided Authentication code. %s', 'really-simple-ssl'),
'<a id="download_codes" href="#">' . esc_html__('Download Backup Codes', 'really-simple-ssl') . '</a>'
);
?>
</p>
<div id="two-factor-qr-code">
<a href="#">
Loading...
<img src="<?php echo esc_url(admin_url('images/spinner.gif')); ?>" alt=""/>
</a>
</div>
<p style="margin-bottom: 10px;">
<i id="totp-key">
<?php
echo esc_html__('Copy setup key', 'really-simple-ssl');
?>
</i>
</p>
<p>
<label for="two-factor-totp-authcode">
<strong><?php echo esc_html__('Authentication Code:', 'really-simple-ssl'); ?></strong>
<?php
/* translators: Example auth code. */
$placeholder = sprintf(esc_html__('eg. %s', 'really-simple-ssl'), '123 456');
?>
<input type="tel" name="two-factor-totp-authcode" id="two-factor-totp-authcode" class="input" value=""
size="20" pattern="[0-9 ]*" placeholder="<?php echo esc_attr($placeholder); ?>"/>
</label>
</p>
<input type="button" class="button button-primary button-large totp-submit" name="two-factor-totp-submit"
id="two-factor-totp-submit"
value="<?php echo esc_html__('Submit', 'really-simple-ssl'); ?>"/>