mirror of
https://github.com/nextcloud/server.git
synced 2026-02-03 20:41:22 -05:00
feat: Add info level result if 2FA is not enforced
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
8475bed525
commit
26cec2d117
1 changed files with 14 additions and 1 deletions
|
|
@ -6,8 +6,10 @@ declare(strict_types=1);
|
|||
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace OCA\Settings\SetupChecks;
|
||||
|
||||
use OC\Authentication\TwoFactorAuth\MandatoryTwoFactor;
|
||||
use OC\Authentication\TwoFactorAuth\ProviderLoader;
|
||||
use OC\Authentication\TwoFactorAuth\ProviderSet;
|
||||
use OCP\IL10N;
|
||||
|
|
@ -18,6 +20,7 @@ class TwoFactorConfiguration implements ISetupCheck {
|
|||
public function __construct(
|
||||
private IL10N $l10n,
|
||||
private ProviderLoader $providerLoader,
|
||||
private MandatoryTwoFactor $mandatoryTwoFactor,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -35,10 +38,20 @@ class TwoFactorConfiguration implements ISetupCheck {
|
|||
$primaryProviders = $providerSet->getPrimaryProviders();
|
||||
if (count($primaryProviders) === 0) {
|
||||
return SetupResult::warning($this->l10n->t('This instance has no second factor provider available.'));
|
||||
}
|
||||
|
||||
$state = $this->mandatoryTwoFactor->getState();
|
||||
|
||||
if (!$state->isEnforced()) {
|
||||
return SetupResult::info(
|
||||
$this->l10n->t(
|
||||
'Second factor providers are available but two-factor authentication is not enforced.'
|
||||
)
|
||||
);
|
||||
} else {
|
||||
return SetupResult::success(
|
||||
$this->l10n->t(
|
||||
'Second factor providers are available: %s.',
|
||||
'Second factor providers are available and enforced: %s.',
|
||||
[
|
||||
implode(', ', array_map(
|
||||
fn ($p) => '"' . $p->getDisplayName() . '"',
|
||||
|
|
|
|||
Loading…
Reference in a new issue