feat: org-scoped admin API keys + cloud credential federation - #15
Merged
Conversation
Two backend features: 1. Org-scoped admin API keys (migration 000177): admin_api_keys gains optional org_id + permissions. NULL org_id keeps legacy superadmin (cross-org) keys; a non-NULL value scopes the key to one org, the prerequisite for the Kubernetes Operator's per-CR authSecretRef. VerifyKey now returns org/permissions; the admin API-key auth path maps them to IsSuperAdmin + org-scoped claims. 2. Cloud credential federation for Terraform (migration 000178): organizations.agent_token_allowed_audiences + agent_tokens.audience. Agent-token issuance accepts an optional audience validated against the per-org allowlist (invalid_target on rejection), plus GET/PUT /organizations/:id/agent-token-audiences endpoints. Clavex only issues a short-lived, correctly-audienced OIDC id_token; the target cloud's own Terraform provider performs the native federation. Docs: docs/cloud-federation.md.
Add the 4 GET/PUT /agent-token-audiences routes (superadmin + org-admin) to the OpenAPI spec, with the allowed_audiences request schema on PUT.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two backend features, ported from internal development.
1. Org-scoped admin API keys (migration 000177)
admin_api_keysgains optionalorg_id+permissions. NULLorg_idkeeps existing keys superadmin-wide (cross-org, legacy); a non-NULL value scopes the key to a single organization — the prerequisite for the Clavex Kubernetes Operator's per-CRauthSecretRefmodel, where the controller must never hold cross-org credentials.VerifyKeyreturns org/permissions; the admin API-key auth callback maps them toIsSuperAdmin+ org-scoped claims. New?org_id=filter on list.2. Cloud credential federation for Terraform (migration 000178)
organizations.agent_token_allowed_audiences(per-org allowlist) +agent_tokens.audience(persisted for audit). Agent-token issuance accepts an optionalaudience, validated against the org allowlist (invalid_targeton rejection), defaulting to the issuer when omitted. NewGET/PUT /api/v1/organizations/:id/agent-token-audiences(superadmin + org-admin-delegate). Clavex only issues a short-lived, signed, correctly-audienced OIDC id_token; theaws/azurerm/googleTerraform provider performs its own native federation. Docs:docs/cloud-federation.md.Test plan
go build ./...cleango vet ./...cleango test ./internal/handler/ ./internal/repository/→ 279 pass