mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-06 23:23:23 +09:00
cc9610cf14cdf2b867febeada2fcb3aa0fde5f7d
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
1c4f433fec |
feat(controller): re-create the BucketAccess of an engine-issued account
The COSI driver issues a Bucket user's keys and never accepts chosen ones, so the password reconciler cannot seed such an account. A separate reconciler creates and owns the BucketAccess a template names, adopts the one the conversion marked so existing keys survive, and copies the keys of the live grant into the account Secret. A mint or a revoke reaches it as a request id on that Secret: a BucketAccess created for an older request is deleted, which makes the sidecar revoke its identity. A mint gets a new BucketAccess; a revoke gets none, so it locks the account out until the next mint. A changed readonly flag or storage pool gives the template another BucketAccess class. The controller records that as a revoke of its own: the account Secret loses its keys and gets a request id and a Revoke entry by the controller, so the revoke path deletes the old grant, creates none, and the next mint is granted under the new class. Re-granting at once would leave keys nobody was shown under a record that says the last mint issued the live ones. A mint the Secret already carries is served under the new class instead. The sidecar has the driver grant an identity before it puts its finalizer on the BucketAccess, so a BucketAccess is deleted only once it carries that finalizer, or once the sidecar can no longer grant it, its class or claim gone or the bucket not ready: a delete in between would skip the driver revoke and leave a working identity behind. A finalizer on the template holds a deleted one until then, so a user removed inside the grant window does not orphan its identity at the provider. The template's status mirrors the account Secret while a request is pending, so a request that never completes does not turn every later one into a conflict, and a lost account Secret is rewritten from the live grant instead of rotating keys under its clients. Lost after a revoke, it is written again as revoked from that status, so it does not take the create path and re-grant keys nobody minted. The password reconciler skips templates that name a BucketAccess and is otherwise unchanged. The account Secret names its BucketAccess in an annotation, which is how the controller tells an engine-issued account Secret from the others. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com> |
||
|
|
a67fa94fdb |
feat(postgres)!: issue user passwords through the credentials API
The chart generated every user's password at render time into <release>-credentials, which tenants could read again at any time and which Helm history kept for MaxHistory revisions, so a deployment whose policy requires a credential shown once could not run PostgreSQL here. The chart now renders a CredentialTemplate per user, and the users move under CloudNativePG's managed roles, each pointing at its account Secret, so the operator creates the role with the SCRAM verifier the Secret holds, applies a changed Secret live, and reverts a password set inside PostgreSQL. Every role is rendered as the init-script created it, because the operator reverts an attribute that differs, revokes a parent role missing from inRoles and clears a comment the spec leaves unset. The init-script stops creating, passwording and altering accounts, where it would be a second writer, and keeps the two things the operator has no field for: the marker membership and the reset of the createrole_self_grant an earlier chart set. Its marking pass waits a bounded time for CloudNativePG to create the declared roles before it marks them. users.app adopts the owner CloudNativePG bootstraps, whose password the instance manager applies again from the bootstrap secret on every pod start, so that secret is the app user's account Secret and both writers apply the one stored verifier. A users.<name>.password left in values draws an admission warning that points at a mint on the user's Credential. createRole is refused on every render path. A role a CREATEROLE user creates makes that user a member of it, CloudNativePG revokes every membership a managed role is not declared to hold, and the revoke fails on the dependent self-grant, so the user would sit in cannotReconcile on ordinary use; there is no per-role switch to leave memberships alone. The account-name checks render with the managed roles too, so a restore cannot bypass them: a user CloudNativePG or PostgreSQL reserves, a database whose derived <name>_admin or <name>_readonly role starts with pg_ or cnpg_ (which makes the CloudNativePG webhook reject the whole Cluster), and a user whose account name is no valid object name are refused. The chart's account naming is pinned to the API's on one table of names. A pre-upgrade hook refuses to let CloudNativePG adopt a role the chart did not mark, because the operator adopts a managed role within seconds of the spec reaching it, before any post-upgrade job could look. It reads the live Cluster first and connects to the database only when the upgrade adds a name CloudNativePG does not manage yet, so a database that is down does not block the resize that might fix it. For each absent declared database role it creates and marks the role as the superuser before the Cluster applies, so no tenant can plant it in the adoption window. The refusal and the create run in one psql session, keyed on a snapshot of the role's existence taken at the top, so a role planted in between collides with the CREATE and stops the hook; the statements are built with format() and \gexec, since psql does not substitute :'role' inside a DO $$ block. Verified on postgres:18: a fresh role is created NOINHERIT, commented and marked, a role planted after the snapshot fails the hook, and an existing unmarked role is refused. The hook reads the Cluster at run time with a ServiceAccount that may get only that Cluster, rather than through a template lookup, which nothing re-renders when the object changes. The flag an earlier chart set when a user held createRole is still read and never set, so such a release keeps refusing to adopt a role it did not mark. The EndpointAttachment e2e suite read testuser's password from that Secret to probe the attached addresses. It now mints one per probe and waits until the application's own Service accepts it, so the attached address is still queried exactly once. BREAKING CHANGE: PostgreSQL passwords are no longer readable from <release>-credentials. A password is issued once, by a mint on the account's Credential in core.cozystack.io, and replaced by the next mint. users.<name>.createRole is refused; a release that sets it keeps its previous chart version and passwords until it is false. Deleting a Postgres application whose release is suspended is refused. The conversion needs a platform variant with migrations enabled. Co-authored-by: IvanHunters <xorokhotnikov@gmail.com> Co-authored-by: Andrei Kvapil <kvapss@gmail.com> Assisted-by: LLM Signed-off-by: Timofei Larkin <lllamnyp@gmail.com> Signed-off-by: Andrei Kvapil <kvapss@gmail.com> |
||
|
|
3c547721fa |
feat(credentials): add the account package
The Cozystack API, the CredentialTemplate controller and the migration tooling must agree on an account Secret's name, its labels, the record of who set the password and when, and the valuesFrom entry that carries a stored value into a chart that reads no Secret. One package holds all of it so the three cannot drift apart. The values key of an account is the SHA-256 of its user name, which fits a valuesFrom targetPath whatever characters the name holds. Co-authored-by: Timofei Larkin <lllamnyp@gmail.com> Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com> |