mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-12-02 13:32:43 -05:00
* Replace bcrypt challenge auth with direct password comparison Closes #2428 Highlights: * Replaced the bcrypt challenge authentication flow with direct password comparison against the bcrypt hash stored in the user configuration. * Removed the `bcrypt.js` dependency, so authentication no longer depends on JavaScript. * Removed the nonce and challenge mechanism and the `nonce` endpoint from the `javascript` controller. * Removed the JavaScript and HTML code used for the previous authentication flow. * Removed the `<noscript>` blocks that were only needed for the previous authentication flow. * Updated `FreshRSS_FormAuth::checkCredentials()` to accept the username, stored bcrypt hash, and plain-text password directly. * The stored password hash must still use the expected bcrypt format. * Empty or whitespace-only passwords are rejected even if the hash would otherwise match. * The bcrypt 72-byte limit is enforced during normal authentication. * Existing bcrypt passwords are handled correctly when the 72-byte limit cuts through a UTF-8 character. * Password input is no longer trimmed before authentication or password changes. Leading and trailing whitespace is therefore kept as part of the password. * Added `FreshRSS_FormAuth::passwordRequirementsMet()` to replace `FreshRSS_password_Util::check()`. * New passwords must be between 7 and 72 bytes by default. * The minimum length check can be disabled where needed. * Password requirements are now checked server-side for all password creation and update paths. * Added client-side byte-length validation for password fields using `TextEncoder` and `data-max-bytes`. * This gives better feedback for UTF-8 passwords. * Server-side validation remains authoritative. * Updated password handling in authentication, re-authentication, self-deletion, user creation, and user update paths so passwords are not trimmed automatically. * Added `FormAuthTest` to cover: * password length limits in bytes * UTF-8 passwords around the 72-byte limit * bcrypt truncation behavior during authentication * malformed and non-bcrypt hashes * empty passwords * authentication failures and log messages * Removed `bcrypt.js` from the documented dependencies and updated the authentication documentation. * Updated the installation and authentication views and JavaScript to match the new password handling. This simplifies the authentication flow, removes the client-side bcrypt challenge, makes password validation consistent between the client and server, and adds more test coverage while keeping compatibility with existing bcrypt password hashes. Because the password is now sent directly to the server instead of being processed by `bcrypt.js`, deployments should use HTTPS. Documentation for HTTPS setup can be handled separately. * Add test case with password truncated down to 71 characters * Compare log messages too during form auth tests * Mark the `getLastLog()` method as impure * Fix: Check password reqs against new password instead of current * Fix: Add custom JS validator for UTF-8, handle cut-off UTF-8 during login * Fix: Enforce password requirements everywhere server-side * Add TODO for updateUser in CLI * make readme * Fix extra.js in install.php * Don't report validity yet if the password is too short or not filled out * Simplify checking of whether to report validity * Fix: Do not trim password from user's input * Also `trim: false` in some userController paths * Use the proper argument order for PHPUnit's `assertSame()` * Remove `maxlength` in favor of `data-max-bytes` But add `pattern` again for some nojs support * make readme * composer run-script translations * Update i18n string for web form admin setting * i18n: fr * Minor whitespace --------- Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
184 lines
7.6 KiB
PHTML
184 lines
7.6 KiB
PHTML
<?php
|
|
declare(strict_types=1);
|
|
/** @var FreshRSS_View $this */
|
|
if (!$this->disable_aside) {
|
|
$this->partial('aside_configure');
|
|
}
|
|
?>
|
|
|
|
<main class="post">
|
|
<form method="post" action="<?= _url('user', 'profile') ?>" data-auto-leave-validation="1">
|
|
<input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
|
|
<h1><?= _t('conf.profile') ?></h1>
|
|
|
|
<div class="form-group">
|
|
<label class="group-name" for="current_user"><?= _t('conf.user.current') ?></label>
|
|
<div class="group-controls">
|
|
<input id="current_user" type="text" disabled="disabled" value="<?= Minz_User::name() ?>" />
|
|
</div>
|
|
</div>
|
|
|
|
<?php if (FreshRSS_Auth::hasAccess('admin')) { ?>
|
|
<div class="form-group">
|
|
<div class="group-controls">
|
|
<label class="checkbox" for="is_admin">
|
|
<input type="checkbox" id="is_admin" disabled="disabled" checked="checked" />
|
|
<?= _t('conf.user.is_admin') ?>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
<?php } ?>
|
|
|
|
<div class="form-group">
|
|
<label class="group-name" for="email"><?= _t('conf.profile.email') ?></label>
|
|
<div class="group-controls">
|
|
<!-- Workaround for Chrome, related to change password section -->
|
|
<input id="ignore" class="ignore-auto-complete" type="text" tabindex="-1" aria-hidden="true" data-no-leave-validation="1" />
|
|
<input id="email" name="email" type="email" value="<?= FreshRSS_Context::userConf()->mail_login ?>" autocomplete="new-password" />
|
|
</div>
|
|
</div>
|
|
|
|
<?php if (FreshRSS_Auth::accessNeedsAction()) { ?>
|
|
<div class="form-group">
|
|
<label class="group-name" for="token"><?= _t('admin.auth.token') ?></label>
|
|
<?php $token = FreshRSS_Context::userConf()->token; ?>
|
|
<div class="group-controls">
|
|
<input id="token" name="token" type="text" value="<?= $token ?>" placeholder="<?= _t('gen.short.blank_to_disable') ?>" autocomplete="new-password" />
|
|
<p class="help"><?= _i('help') ?> <?= _t('admin.auth.token_help') ?></p>
|
|
<kbd><?= Minz_Url::display(['a' => 'rss', 'params' => ['user' => Minz_User::name() ?? '',
|
|
'token' => $token, 'hours' => FreshRSS_Context::userConf()->since_hours_posts_per_rss]], 'html', true) ?></kbd>
|
|
<p class="help"><?= _i('help') ?> <?= _t('conf.query.help') ?></a></p>
|
|
</div>
|
|
</div>
|
|
<?php } ?>
|
|
|
|
<?php
|
|
$open = Minz_Session::paramBoolean('open');
|
|
Minz_Session::_param('open', false);
|
|
?>
|
|
|
|
<details class="form-advanced" <?= $open ? ' open="open"' : ''?>>
|
|
<summary class="form-advanced-title"><?= _t('conf.profile.change_password') ?></summary>
|
|
<div class="form-group">
|
|
<label class="group-name" for="currentPasswordPlain"><?= _t('conf.profile.current_password') ?></label>
|
|
<div class="group-controls">
|
|
<input type="hidden" id="username" value="<?= Minz_User::name() ?? '' ?>" />
|
|
<div class="stick">
|
|
<input
|
|
type="password" id="currentPasswordPlain" name="passwordPlain" class="passwordPlain"
|
|
data-required-if-open="1" data-no-leave-validation="1" />
|
|
<button type="button" class="btn toggle-password"><?= _i('key') ?></button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="group-name" for="newPasswordPlain"><?= _t('conf.profile.new_password') ?></label>
|
|
<div class="group-controls">
|
|
<div class="stick">
|
|
<input
|
|
type="password" id="newPasswordPlain" name="newPasswordPlain" autocomplete="new-password"
|
|
minlength="<?= FreshRSS_FormAuth::MIN_PASSWORD_LENGTH ?>"
|
|
pattern=".{<?= FreshRSS_FormAuth::MIN_PASSWORD_LENGTH ?>,<?= FreshRSS_FormAuth::MAX_PASSWORD_LENGTH ?>}"
|
|
data-max-bytes="<?= FreshRSS_FormAuth::MAX_PASSWORD_LENGTH ?>"
|
|
data-required-if-open="1" />
|
|
<button type="button" class="btn toggle-password"><?= _i('key') ?></button>
|
|
</div>
|
|
<p class="help">
|
|
<?= _i('help') ?> <?= _t('conf.profile.password_format') ?>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="group-name" for="confirmPasswordPlain"><?= _t('conf.profile.confirm_new_password') ?></label>
|
|
<div class="group-controls">
|
|
<div class="stick">
|
|
<input
|
|
type="password" id="confirmPasswordPlain" name="confirmPasswordPlain" autocomplete="new-password"
|
|
minlength="<?= FreshRSS_FormAuth::MIN_PASSWORD_LENGTH ?>"
|
|
pattern=".{<?= FreshRSS_FormAuth::MIN_PASSWORD_LENGTH ?>,<?= FreshRSS_FormAuth::MAX_PASSWORD_LENGTH ?>}"
|
|
data-max-bytes="<?= FreshRSS_FormAuth::MAX_PASSWORD_LENGTH ?>"
|
|
data-required-if-open="1" />
|
|
<button type="button" class="btn toggle-password"><?= _i('key') ?></button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</details>
|
|
|
|
<div class="form-group form-actions">
|
|
<div class="group-controls">
|
|
<button type="submit" class="btn btn-important"><?= _t('gen.action.submit') ?></button>
|
|
<button type="reset" class="btn"><?= _t('gen.action.cancel') ?></button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
|
|
|
|
<h2><?= _t('conf.profile.api') ?></h2>
|
|
<?php if (FreshRSS_Context::systemConf()->api_enabled) { ?>
|
|
<form method="post" action="<?= _url('api', 'updatePassword') ?>">
|
|
<input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
|
|
|
|
<div class="form-group">
|
|
<label class="group-name" for="apiPasswordPlain"><?= _t('conf.profile.password_api') ?></label>
|
|
<div class="group-controls">
|
|
<div class="stick">
|
|
<input type="password" id="apiPasswordPlain" name="apiPasswordPlain" autocomplete="new-password"
|
|
<?php if (FreshRSS_Context::userConf()->apiPasswordHash != '') {?>
|
|
placeholder="<?= _t('conf.profile.api.api_set') ?>"
|
|
<?php } else {?>
|
|
placeholder="<?= _t('conf.profile.api.api_not_set') ?>"
|
|
<?php } ?>
|
|
pattern=".{7,}" <?= FreshRSS_password_Util::cryptAvailable() ? '' : 'disabled="disabled" ' ?>/>
|
|
<button type="button" class="btn toggle-password"><?= _i('key') ?></button>
|
|
</div>
|
|
<p class="help"><?= _i('help') ?> <?= _t('conf.profile.api.check_link', Minz_Url::display('/api/', 'html', true)) ?></p>
|
|
<p class="help"><?= _i('help') ?> <?= _t('conf.profile.api.documentation_link') ?></p>
|
|
<p class="help"><?= _i('warning') ?> <?= _t('conf.profile.api.security_warning') ?></p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group form-actions">
|
|
<div class="group-controls">
|
|
<button type="submit" class="btn btn-important"><?= _t('gen.action.submit') ?></button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
<?php } else { ?>
|
|
<div class="form-group">
|
|
<label class="group-name"></label>
|
|
<div class="group-controls">
|
|
<?= _t('conf.profile.api.disabled') ?>
|
|
<p class="help"><?= _i('help') ?> <?= _t('conf.profile.api.help') ?></p>
|
|
</div>
|
|
</div>
|
|
<?php } ?>
|
|
|
|
<?php if (!FreshRSS_Auth::hasAccess('admin')) { ?>
|
|
<h2><?= _t('conf.profile.delete') ?></h2>
|
|
|
|
<form method="post" action="<?= _url('user', 'delete') ?>">
|
|
<input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
|
|
|
|
<p class="alert alert-warn"><span class="alert-head"><?= _t('gen.short.attention') ?></span> <?= _t('conf.profile.delete.warn') ?></p>
|
|
|
|
<div class="form-group">
|
|
<label class="group-name" for="passwordPlain"><?= _t('gen.auth.password') ?></label>
|
|
<div class="group-controls">
|
|
<div class="stick">
|
|
<input type="password" id="passwordPlain" name="passwordPlain" class="passwordPlain" required="required" />
|
|
<button type="button" class="btn toggle-password"><?= _i('key') ?></button>
|
|
</div>
|
|
<br />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group form-actions">
|
|
<div class="group-controls">
|
|
<input type="hidden" name="username" id="username" value="<?= Minz_User::name() ?>" />
|
|
<button type="submit" class="btn btn-attention confirm"><?= _t('gen.action.remove') ?></button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
<?php } ?>
|
|
</main>
|