Skip to content

fix(core): move twofactor_backupcodes to defaultEnabled - #65272

Merged
susnux merged 1 commit into
masterfrom
fix/twofactor-backupcodes-default-enabled
Dec 5, 2026
Merged

susnux merged 1 commit into
masterfrom
fix/twofactor-backupcodes-default-enabled

Conversation

@DmySyz

@DmySyz DmySyz commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

twofactor_backupcodes is a 2FA backup-code provider, not core server infrastructure. As an alwaysEnabled app it cannot be disabled by admins, which causes operational issues:

  • The migration job (fixMissingProviderStates) writes provider-state rows on every upgrade even when 2FA is not used
  • Backup-code reminder notifications fire after upgrades
  • Deployments that use alternative 2FA backup mechanisms or no 2FA at all cannot opt out

Every other 2FA provider (twofactor_totp, twofactor_nextcloud_notification) is either defaultEnabled or not enabled by default. Moving twofactor_backupcodes to defaultEnabled preserves the enabled-by-default behavior for fresh installs while allowing admins to disable it.

Alternative to: #64371

Checklist

AI (if applicable)

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

@DmySyz
DmySyz requested a review from a team as a code owner October 7, 2026 11:51
@DmySyz
DmySyz requested review from come-nc, icewind1991, leftybournes, provokateurin and salmart-dev and removed request for a team October 7, 2026 11:51
@github-actions

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

…abled

twofactor_backupcodes is a 2FA backup-code provider, not core server
infrastructure. As an alwaysEnabled app it cannot be disabled by
admins, which causes operational issues:

- The migration job (fixMissingProviderStates) writes provider-state
  rows on every upgrade even when 2FA is not used
- Backup-code reminder notifications fire after upgrades
- Deployments that use alternative 2FA backup mechanisms or no 2FA
  at all cannot opt out

Every other 2FA provider (twofactor_totp, twofactor_nextcloud_notification)
is either defaultEnabled or not enabled by default. Moving
twofactor_backupcodes to defaultEnabled preserves the enabled-by-default
behavior for fresh installs while allowing admins to disable it.

Signed-off-by: dsyzov <dmytro.syzov@nextcloud.com>
@susnux
susnux force-pushed the fix/twofactor-backupcodes-default-enabled branch from 0217262 to 635ca87 Compare December 5, 2026 20:11
@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

Possible performance regression detected

Show Output
8 queries added

= /remote.php/dav/files/test
= /remote.php/dav/files/test/test.txt
= /remote.php/dav/files/test/many_files
= /remote.php/dav/files/test/new_file.txt
≠ /remote.php/dav/files/test/new_file.txt with 8 queries added
  - UPDATE "oc_filecache" SET "size" = :dcValue4 WHERE ("fileid" = :dcValue1) AND ("storage" = :dcValue2) AND (("size" <> :dcValue3) OR ("size" IS NULL))
  - UPDATE "oc_filecache" SET "size" = :dcValue4 WHERE ("fileid" = :dcValue1) AND ("storage" = :dcValue2) AND (("size" <> :dcValue3) OR ("size" IS NULL))
  - SELECT "path" FROM "oc_filecache" WHERE ("storage" = :dcValue1) AND ("fileid" = :dcValue2)
  - SELECT "path" FROM "oc_filecache" WHERE ("storage" = :dcValue1) AND ("fileid" = :dcValue2)
  + SELECT "storage", "path", "mimetype" FROM "oc_filecache" WHERE "fileid" = :dcValue1
  + SELECT "storage_id", "root_id", "user_id", "mount_point", "mount_id", "f"."path", "mount_provider_class" FROM "oc_mounts" "m" INNER JOIN "oc_filecache" "f" ON "m"."root_id" = "f"."fileid" WHERE ("m"."storage_id" = :dcValue1) AND ("f"."storage" = :dcValue2) AND (("f"."fileid" = :dcValue3) OR ("f"."path" = '') OR (("f"."path" || :dcValue4) = SUBSTR(:dcValue5, :dcValue6, LENGTH("f"."path") + :dcValue7))) AND ("user_id" = :dcValue8)
  + SELECT "filecache"."fileid", "storage", "path", "path_hash", "filecache"."parent", "filecache"."name", "mimetype", "mimepart", "size", "mtime", "storage_mtime", "encrypted", "filecache"."etag", "filecache"."permissions", "checksum", "unencrypted_size", "metadata_etag", "creation_time", "upload_time", "meta"."json" AS "meta_json", "meta"."sync_token" AS "meta_sync_token" FROM "oc_filecache" "filecache" LEFT JOIN "oc_filecache_extended" "fe" ON "filecache"."fileid" = "fe"."fileid" LEFT JOIN "oc_files_metadata" "meta" ON "filecache"."fileid" = "meta"."file_id" WHERE ("filecache"."fileid" = :dcValue1) AND ("storage" = :dcValue2)
  + DELETE FROM "oc_filecache" WHERE ("storage" = :dcValue1) AND ("fileid" = :dcValue2)
  + DELETE FROM "oc_filecache_extended" WHERE "fileid" = :dcValue1
  + SELECT "file_id", "json", "sync_token" FROM "oc_files_metadata" WHERE "file_id" IN (:dcValue1)
  + SELECT "file_id", "json", "sync_token" FROM "oc_files_metadata" WHERE "file_id" IN (:dcValue1)
  + DELETE FROM "oc_files_metadata" WHERE "file_id" IN (:dcValue1)
  + DELETE FROM "oc_files_metadata_index" WHERE "file_id" IN (:dcValue1)
  + SELECT "fileid" FROM "oc_filecache" WHERE ("storage" = :dcValue1) AND ("path_hash" = :dcValue2)
  + UPDATE "oc_file_locks" SET "lock" = :dcValue1, "ttl" = :dcValue2 WHERE ("key" = :dcValue3) AND ("lock" = :dcValue4)
  + SELECT "filecache"."fileid", "storage", "path", "path_hash", "filecache"."parent", "filecache"."name", "mimetype", "mimepart", "size", "mtime", "storage_mtime", "encrypted", "filecache"."etag", "filecache"."permissions", "checksum", "unencrypted_size", "metadata_etag", "creation_time", "upload_time", "meta"."json" AS "meta_json", "meta"."sync_token" AS "meta_sync_token" FROM "oc_filecache" "filecache" LEFT JOIN "oc_filecache_extended" "fe" ON "filecache"."fileid" = "fe"."fileid" LEFT JOIN "oc_files_metadata" "meta" ON "filecache"."fileid" = "meta"."file_id" WHERE ("path_hash" = :dcValue1) AND ("storage" = :dcValue2)
= ./occ profiler:list

@susnux
susnux merged commit 4d8b735 into master Dec 5, 2026
125 of 126 checks passed
@susnux
susnux deleted the fix/twofactor-backupcodes-default-enabled branch December 5, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants