Timofei Larkin fa9b8f07a2 feat(postgres)!: mint tenant passwords through the credentials API (#4922)
## What this PR does

Postgres passwords are no longer readable from `<release>-credentials`,
which every `use` member and every parent tenant can read today, and
`users.<name>.password` is ignored. An administrator mints a password on
the user's `Credential` and sees it once. The account Secret stores only
the SCRAM verifier, CloudNativePG applies it, and the next mint or a
revoke kills the previous password. This is the Postgres part of the
user secrets API design (cozystack/community#137) on top of #4921.

- The chart renders one `scram-sha-256` CredentialTemplate per user and
points each managed role at its account Secret.
- The CloudNativePG bootstrap secret of the `app` owner is now that
user's account Secret, so the chart no longer generates a password into
`<release>-app-owner`.
- `users.<name>.createRole: true` is refused at render. A CREATEROLE
user becomes a member of each role it creates, CloudNativePG revokes
every membership a managed role does not declare, and that revoke fails
on the dependent grant, so the role gets stuck in `cannotReconcile`.
CloudNativePG has no per-role switch to leave memberships alone.
- `credentials-migrate` and migration 64 convert existing releases. The
pre-upgrade hook applies the CredentialTemplate CRD, writes each account
Secret from the current password as a verifier, and marks the release
for seeding only when every account got one. The finish Job runs under
its own `cozystack-credentials-migration-64` identity and removes
`<release>-credentials` once the controller adopted the accounts. A
transient API error is retried before a release is recorded as left out.

Live results, on a three-node test cluster upgraded from 1.7.1, with a
client logging in every second:

- Upgrade: the migration wrote the verifiers, the controller adopted
them, the finish Job removed the old Secret, and the client logged in
1014 times with no failure. A later run that upgraded all converted
engines at once (migrations 64-71) also had no Postgres failure, for
`web` and for the database owner `app`.
- A mint returns a password that logs in over TCP; the next mint and a
revoke each kill the previous password within 2 s. A stale precondition
gets 409 with no password, and a tenant viewer can't mint.
- Removing a user removes its template, Secret and role. `createRole:
true` fails at render.
- After a mint on `app`, the password survived a primary failover and
two restarts: CloudNativePG did not reset it from the bootstrap Secret.

Breaking for users: passwords can't be read any more, so clients switch
to a minted one after the upgrade. A release with `users.*.createRole:
true` is left out of the conversion: it keeps its previous chart
version, raises `CredentialsMigrationIncomplete`, and fails every
upgrade until the flag is set to `false`.

The red `E2E (in-tree)` comes from `mariadb-2-backup-roundtrip`, where
SeaweedFS rejected a freshly granted BucketAccess key before any
Postgres code ran; the three postgres tests pass.

### 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 Postgres note for the credentials API docs
(cozystack/website#753) and an upgrade note that clients must mint and
`createRole` must be off
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: needed, `cozystack_postgres` 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:

### Release note

```release-note
feat(postgres)!: Postgres passwords are issued through the credentials API and are no longer readable from `<release>-credentials`; `users.<name>.password` is ignored. An administrator mints a password on the user's Credential; it is shown once and applies within seconds. Existing passwords keep working through the upgrade: migration 64 converts every Postgres release and then removes the old Secret. `users.<name>.createRole: true` is no longer supported: a release that sets it is not converted, raises `CredentialsMigrationIncomplete` and fails its upgrades until the flag is set to `false`. Switch clients to minted passwords after the upgrade.
```
2026-12-01 00:44:53 +03: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%
Shell 33.2%
TypeScript 6.7%
Go Template 4.7%
Makefile 1.3%
Other 1%