Andrei Kvapil 1791336e04 feat(mongodb)!: mint tenant passwords through the credentials API (#5380)
## What this PR does

MongoDB passwords are no longer readable from the per-user
`<release>-user-<name>` Secrets, and tenants lose the `databaseAdmin`
login from `<release>-credentials`. Every tenant tier can read both
today. An administrator mints a password on the user's `Credential` and
sees it once, the operator applies it live, and the next mint or a
revoke kills it. MongoDB computes SCRAM itself, so the account Secret
keeps the plaintext, readable only by the platform. A user removed from
`users` is now also dropped from the database. This is the MongoDB part
of the user secrets API design (cozystack/community#137).

Stacked on #5379. Review only the top three commits:

- `credentials-migrate` gets `--source-key` and `--source-per-account`,
to read one source Secret per user.
- The chart renders a `plaintext` CredentialTemplate per user, points
`passwordSecretRef` at its account Secret and hides
`<release>-credentials` from tenants. Every declared user holds an empty
marker role, and a post-upgrade hook drops users that hold it but are no
longer declared, since the Percona operator never drops a user removed
from `spec.users`.
- Migration 67 seeds the account Secrets from the per-user Secrets
before the chart switches. Its finish Job deletes the per-user Secrets
Helm left behind.

Tested on a three-node cluster, fresh install: a minted password logs in
after 3 s, the old one fails 3 s after the next mint, revoke works, no
pod restarts. That run showed a removed user staying in the database,
which the last commit fixes. Full upgrade from 1.7.1 on the same
cluster, all engines at once with a client loop each: migrations 64-71
ran in order and every account was adopted with its old password. The
MongoDB loop had one server-selection timeout during the platform roll
and no authentication error. After the upgrade, a removed user is gone
from `admin.system.users`.

Breaking for users: tenants lose `databaseAdmin`, their only admin login
today. Passwords can't be read any more. A user name that collides with
a system user, maps to an invalid account name (such as `_backup`), is
longer than 63 characters, or maps to the same account as another name
(`a.b` and `a-b`) now fails the render. A user removed from `users` is
dropped on the next upgrade.

Open questions:

1. Should the conversion rotate `databaseAdmin`? Tenants could read it.
2. Without `databaseAdmin`, no tenant user can manage users or the
cluster. Add a per-database admin role, or leave it like that?
3. The drop hook fails the upgrade if there's no writable primary within
5 minutes, on purpose. Is that the right trade?

### Screenshots

No UI change.

### Downstream repositories

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up: needed, a MongoDB note for the credentials API docs
(cozystack/website#753) and an upgrade note that tenants lose
`databaseAdmin`
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: needed, `cozystack_mongodb` still sends
`users.<name>.password`
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up: needed, the MongoDB row in the design, and the
`databaseAdmin` row once question 1 is decided

### Release note

```release-note
feat(mongodb)!: MongoDB passwords are issued through the credentials API. The per-user `<release>-user-<name>` Secrets are removed, `users.<name>.password` is ignored, and tenants can no longer read `databaseAdmin`. An administrator mints a password on the user's Credential; it is shown once and applies within seconds without a restart. A user removed from `users` is now dropped from MongoDB. Existing passwords keep working through the upgrade. Clients that log in as `databaseAdmin` must move to a declared user, and user names that collide with a system user must be renamed before upgrading.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* MongoDB user passwords are now managed through platform account
credentials, with one-time issuance and revocation. Password values in
app configuration are ignored, and reserved MongoDB system-user names
are rejected.
  * Obsolete chart-managed MongoDB users are removed during upgrades.
* Migration support transfers existing MongoDB passwords to
platform-managed account credentials.

* **Bug Fixes**
* MongoDB credential Secrets are excluded from tenant access and
enumeration.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-12-02 11:45:53 -05:00
2026-11-04 00:56:56 +01:00
2025-10-08 09:43:34 +05:00
2024-02-08 12:04:32 +01:00

Cozystack Cozystack

GitHub Release Apache-2.0 License Commit activity OpenSSF Best Practices OpenSSF Scorecard CLOMonitor Support

Cozystack

Cozystack is a free and open-source platform and framework for building clouds.

Cozystack is a CNCF Sandbox project that was originally built and sponsored by Ænix.

With Cozystack, you can transform a bunch of servers into an intelligent system with a simple REST API for spawning Kubernetes clusters, Database-as-a-Service, virtual machines, load balancers, HTTP caching services, and other services with ease.

Use Cozystack to build your own cloud or provide a cost-effective development environment.

Cozystack user interface

Use-Cases

Documentation

The documentation is located on the cozystack.io website.

Read the Getting Started section for a quick start.

If you encounter any difficulties, start with the troubleshooting guide and work your way through the process that we've outlined.

Versioning

Versioning adheres to the Semantic Versioning principles.
A full list of the available releases is available in the GitHub repository's Release section.

Contributions

Contributions are highly appreciated and very welcomed!

In case of bugs, please check if the issue has already been opened by checking the GitHub Issues section. If it isn't, you can open a new one. A detailed report will help us replicate it, assess it, and work on a fix.

You are welcome to take on the fix yourself. Commits are used to generate the changelog, and their author will be referenced in it.

If you have a concrete feature request, open an issue. For a cross-cutting or architectural change, open a design proposal in the community repo. For questions or early ideas, use GitHub Discussions. See CONTRIBUTING.md for the full routing.

Community

You are welcome to join us in #cozystack, on either CNCF Slack (get an invite) or Kubernetes Slack (get an invite), in our Telegram group, and at our community meetings. Add them to your Google Calendar or iCal for convenience.

Project documents

Document What it covers
Governance How decisions are made and who makes them
Contributor Ladder How to grow from contributor to maintainer
Maintainers Who maintains the project
Code of Conduct What we expect of each other
Security Policy Reporting a vulnerability, and which releases get fixes
Adopters Who runs Cozystack in production
Roadmap Where the project is going

License

Cozystack is licensed under Apache 2.0.
The code is provided as-is with no warranties.

Commercial Support

A list of companies providing commercial support for this project can be found on official site.

Languages
Go 53.3%
Shell 33.1%
TypeScript 6.6%
Go Template 4.7%
Makefile 1.2%
Other 1%