Skip to content

Conversation

@come-nc
Copy link
Contributor

@come-nc come-nc commented Jan 27, 2026

Summary

Add warning if no two factor auth provider is found.

Checklist

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@come-nc come-nc self-assigned this Jan 27, 2026
@come-nc come-nc added the 3. to review Waiting for reviews label Jan 27, 2026
@come-nc come-nc requested review from Altahrim, ArtificialOwl, icewind1991 and salmart-dev and removed request for a team January 27, 2026 16:07
@come-nc
Copy link
Contributor Author

come-nc commented Jan 27, 2026

/backport to stable33

@come-nc
Copy link
Contributor Author

come-nc commented Jan 27, 2026

/backport to stable32

Comment on lines +34 to +36
if ($user === null) {
$allApps = $this->appManager->getEnabledApps();
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels weird, not sure why tho . least privilege maybe?

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Comment on lines +31 to +42
public function run(): SetupResult {
$providers = $this->providerLoader->getProviders();
if (count($providers) === 0) {
return SetupResult::warning($this->l10n->t('This instance has no second factor provider available.'));
} else {
return SetupResult::success(
$this->l10n->t(
'Second factor providers are available: %s.',
[
implode(', ', array_map(
fn ($p) => '"' . $p->getDisplayName() . '"',
$providers)
Copy link
Contributor

@szaimen szaimen Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder, shouldn't the test also check if 2FA is actually enabled for users or even enforced?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can (and should) not loop over all users in a setup check

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but maybe we could check for the system config "twofactor_enforced": "true", here?

Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments. I don't think this should succeed when only backup codes are available. It needs at least one real 2FA provider.

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy new year!

}

public function getName(): string {
return $this->l10n->t('Two factor configuration');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think it should be either two-factor authentication or second factor configuration. Two factor configuration sounds wrong.

}

public function run(): SetupResult {
$providers = $this->providerLoader->getProviders();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will give you one provider if only twofactor_backup is enabled. That provider alone is not usable as 2FA.

You could fetch the provider set from \OC\Authentication\TwoFactorAuth\Manager::getProviderSet and use \OC\Authentication\TwoFactorAuth\ProviderSet::getPrimaryProviders instead.

Downside is that getProviderSet is specific to a user.

Or you duplicate the logic here and exclude the backup codes provider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add warning to Setup Checks when 2FA is not enabled and when instance is outdated

6 participants