Skip to content

refactor(setup): unify generated DB password handling across MySQL and PostgreSQL#59092

Merged
provokateurin merged 3 commits intomasterfrom
jtr/refactor-setup-central-db-gen
Apr 13, 2026
Merged

refactor(setup): unify generated DB password handling across MySQL and PostgreSQL#59092
provokateurin merged 3 commits intomasterfrom
jtr/refactor-setup-central-db-gen

Conversation

@joshtrichards
Copy link
Copy Markdown
Member

@joshtrichards joshtrichards commented Mar 20, 2026

Summary

This refactor moves generated database-password creation into AbstractDatabase and reuses it in both MySQL and PostgreSQL setup flows.

Previously:

  • MySQL generated a 30-character password with mixed character classes
  • PostgreSQL generated a 30-character alphanumeric password via Server::get(ISecureRandom::class)

With this change:

  • password generation is centralized in one helper
  • MySQL keeps the existing stronger generation strategy
  • PostgreSQL now uses the same generation strategy
  • the PostgreSQL setup no longer relies on Server::get()

Why:

  • removes duplicated password-generation logic
  • keeps setup behavior consistent across database backends
  • avoids service-locator usage where dependency injection is already available

Notes:

  • generated symbols are filtered to avoid characters that are problematic in SQL string contexts: ", \, ', and ```

Checklist

AI (if applicable)

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

Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
@joshtrichards joshtrichards added this to the Nextcloud 34 milestone Mar 20, 2026
@joshtrichards joshtrichards added feature: install and update technical debt 🧱 🤔🚀 ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring) 3. to review Waiting for reviews labels Mar 20, 2026
@joshtrichards joshtrichards marked this pull request as ready for review March 20, 2026 14:03
@joshtrichards joshtrichards requested a review from a team as a code owner March 20, 2026 14:03
@joshtrichards joshtrichards requested review from ArtificialOwl, CarlSchwan, icewind1991, nickvergessen and salmart-dev and removed request for a team March 20, 2026 14:03
@joshtrichards joshtrichards changed the title refactor(setup): Centralize database password generation in AbstractDatabase refactor(setup): unify generated DB password handling across MySQL and PostgreSQL Apr 13, 2026
@joshtrichards joshtrichards added the feature: database Database related DB label Apr 13, 2026
@provokateurin provokateurin merged commit d7043e5 into master Apr 13, 2026
202 of 206 checks passed
@provokateurin provokateurin deleted the jtr/refactor-setup-central-db-gen branch April 13, 2026 07:58
@nextcloud-bot nextcloud-bot mentioned this pull request Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews feature: database Database related DB feature: install and update ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring) technical debt 🧱 🤔🚀

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants