Andrei Kvapil 69f5d07c1d feat(mariadb)!: mint tenant passwords through the credentials API (#5379)
## What this PR does

MariaDB passwords are no longer readable from `<release>-credentials`,
which every `use` member and every parent tenant can read today. An
administrator mints a password on the user's `Credential` and sees it
once. The database stores only its `mysql_native_password` hash, and the
next mint or a revoke kills it within seconds. `root` stays the
platform's account and is hidden from tenants. This is the MariaDB part
of the user secrets API design (cozystack/community#137).

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

- `credentials-migrate` gets `--skip-account`, so no account is written
for `users.root`, which the chart always ignored.
- The chart renders a `mysql-native` CredentialTemplate per user and
points each `User` at its account Secret through
`passwordHashSecretKeyRef`.
- Migration 66 writes the hashed account Secrets before the chart
switches. Its finish Job removes the tenant keys from
`<release>-credentials` and keeps `root`.

Tested on a three-node cluster, fresh install: a minted password logs in
after 3 s, the old one gets `Access denied` 3 s after the next mint,
revoke works, and removing a user drops the `mysql.user` row too. 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 MariaDB client loop had no failures.

Breaking for users: passwords can't be read any more. A user name longer
than 63 characters, one that starts or ends with a character other than
a letter or digit (such as `_backup`), or two names that map to one
account (`a.b` and `a-b`), now fail the render; such a release is not
converted. A password changed inside MariaDB is reverted by the
operator.

Open questions:

1. `root` is not rotated, although the design says it should be. The
operator reads it on every reconcile and the pods take it as
`MARIADB_ROOT_PASSWORD` for their probes, so changing it needs a
coordinated restart. So the `root` password tenants could read stays
valid. Accept that and fix the design, or rotate it before merge?
2. Not from this diff: the backup CronJob reads `root-password` from a
Secret `<release>` that doesn't exist. It needs a separate fix.

### 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 MariaDB note for the credentials API docs
(cozystack/website#753), an upgrade note, and `backup-classes.md` still
points at credentials in `<release>-credentials`
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: needed, `mariadb_schema.go` tells users the password is in
`mariadb-<name>-credentials`
- [ ]
[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 only if `root` stays unrotated, to fix the design

### Release note

```release-note
feat(mariadb)!: MariaDB passwords are issued through the credentials API and are no longer readable from `<release>-credentials`. An administrator mints a password on the user's Credential; it is shown once and applies within seconds. `root` is no longer visible to tenants. Existing passwords keep working through the upgrade. A user name longer than 63 characters, one that starts or ends with a character other than a letter or digit (such as `_backup`), or two names that map to one account name (such as `a.b` and `a-b`), now fail the render and keep the release unconverted until renamed. Switch clients to minted passwords after the upgrade.
```


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

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

## Summary by CodeRabbit

* **New Features**
* MariaDB tenant accounts now use individually issued credentials.
Passwords are returned when minted, while only password hashes are
stored; credentials can be rotated or revoked through the credentials
API.
* Existing MariaDB accounts are migrated to the new credential system.
The platform-managed `root` account remains separate from tenant
accounts.
* **Bug Fixes**
* Tenant-supplied `password` values and `root` entries are ignored, with
admission warnings for supplied passwords. Password changes made
directly in MariaDB are reverted during reconciliation.
  * Tenant access to MariaDB credentials Secrets is restricted.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-12-02 07:18:24 -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%