Skip to content

Two factor authentication for both login variants - #8597

Open
pabzm wants to merge 1 commit into
mainfrom
2fa
Open

Two factor authentication for both login variants#8597
pabzm wants to merge 1 commit into
mainfrom
2fa

Conversation

@pabzm

@pabzm pabzm commented Aug 20, 2026

Copy link
Copy Markdown
Member

This adds optional two factor authentication based on shared TOTP-secrets to both login variants (password and AIO token authentication).

The 2FA can be enabled as soon as the containers are running in a section below the backup configuration. As long as it is not enabled, the AIO UI shows a warning at the top, and inside the Nextcloud a notification is shown to all Nextcloud admins, strongly recommending to enable it. The Nextcloud admin notification is sent via the mastercontainer's cron.sh, thus will be renewed whenever it is dismissed.

In order to show the notices, this PR includes a notification system for the AIO UI, providing two variants: notices, and warnings. Notices have a green background and border and vanish after 5 seconds. Warnings have a orange-leaning yellow background and border and don't vanish (and can't be dismissed manually, neither).

Another visual improvement is highlighted section headlines: If the URL hash matches an h2 element's ID, the h2 is highlighted and if the h2 is followed by a detail element, that detail is opened. If effect, browsing to #two-factor-auth jumps to the section, which is highlighted and opened already (as shown in the second screenshot below).

The libraries are the same as used in https://github.com/nextcloud/twofactor_totp, to stay consistent with Nextcloud.

Screenshots are below.

Summary

  • The PR was tested and verified that it works locally
  • Or will be tested after merge on a dedicated test instance (available for maintainers)
  • Sign-off message is added to all commits
  • Tests (playwright if possible) are included
  • Screenshots before/after for front-end changes
  • Documentation has been updated or is not required
  • Labels added where applicable (ex: bug/enhancement, 3. to review, feature component)
  • Milestone next added

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Screenshots

After the containers are up and running:

Screenshot 2026-08-20 at 09 58 25

After the link in the warning was clicked:

Screenshot 2026-08-20 at 09 58 53

The same section if the link wasn't clicked but the page was scrolled down:

Screenshot 2026-08-20 at 09 59 16

After 2FA was enabled successfully:

Screenshot 2026-08-20 at 10 00 01

The section's detail has a different summary and changed content now:

Screenshot 2026-08-20 at 10 00 36

Logging in with the password (after stopping the containers) requires a 2FA code now:

Screenshot 2026-08-20 at 10 09 11

If logging in via Nextcloud's admin link (AIO token), the 2FA code is required, too:

Screenshot 2026-08-20 at 10 01 16

Inside Nextcloud a nagging notification is shown to all admins:

Screenshot 2026-08-20 at 11 52 04

This adds optional two factor authentication based on shared
TOTP-secrets to both login variants (password and AIO token
authentication).

The 2FA can be enabled as soon as the containers are running in a
section below the backup configuration. As long as it is not enabled,
the AIO UI shows a warning at the top, and inside the Nextcloud a
notification is shown to all Nextcloud admins, strongly recommending to
enable it. The Nextcloud admin notification is sent via the
mastercontainer's `cron.sh`, thus will be renewed whenever it is
dismissed.

In order to show the notices, this PR includes a notification system for
the AIO UI, providing two variants: notices, and warnings. Notices have
a green background and border and vanish after 5 seconds. Warnings have
a orange-leaning yellow background and border and don't vanish (and
can't be dismissed manually, neither).

Another visual improvement is highlighted section headlines: If the URL
hash matches an `h2` element's ID, the `h2` is highlighted and if the
`h2` is followed by a `detail` element, that `detail` is opened. If
effect, browsing to `#two-factor-auth` jumps to the section, which is
highlighted and opened already (as shown in the second screenshot
below).

Signed-off-by: Pablo Zmdl <pablo@nextcloud.com>
AI-assistant: Claude Opus 4.8
@pabzm pabzm added this to the next milestone Aug 20, 2026
@pabzm pabzm added 2. developing Work in progress enhancement New feature or request labels Aug 20, 2026
@pabzm

pabzm commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

The "Docker lint" check is unrelated to the changes of this PR (will be improved or fixed in #8598)

@pabzm
pabzm requested a review from szaimen August 20, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. developing Work in progress enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant