feat(provision): service token on product lifecycle calls; stage/prod provision URLs
ci / shared (pull_request) Successful in 13s
ci / test (pull_request) Successful in 22m26s
ci / image (pull_request) Skipped

The registry now authenticates POST …/provision with its own
client_credentials token (tenant-registry-svc-<env>; products check aud +
azp). Migration 0005 seeds the Prüfwerk and Firmwerk provision URLs per
environment; the memory catalog (dev) keeps none.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
This commit is contained in:
Sharang ParnerkarandClaude Fable 5.1 committed 2026-09-12 11:04:52 +02:00
1 parent 209524e5ac
commit 5f849c54c6
6 files changed
+24 -1

No files matched your search

+5
View File
@@ -91,4 +91,9 @@ type Adapter interface {
// Health pings the admin endpoint. Used by readyz and the cluster cold-
// start sequence (INFRASTRUCTURE.md §10 scenario F).
Health(ctx context.Context) error
// ServiceToken returns a client_credentials access token of the
// registry's own Keycloak client — the bearer for product lifecycle
// calls (PRODUCT_INTEGRATION_SPEC 2.0 §4.1; products verify aud + azp).
ServiceToken(ctx context.Context) (string, error)
}
+3
View File
@@ -58,6 +58,9 @@ func NewHTTPAdapter(cfg HTTPConfig) *HTTPAdapter {
// ─── auth ────────────────────────────────────────────────────────────────
// ServiceToken exposes the cached client_credentials token (see Adapter).
func (a *HTTPAdapter) ServiceToken(ctx context.Context) (string, error) { return a.token(ctx) }
func (a *HTTPAdapter) token(ctx context.Context) (string, error) {
a.mu.Lock()
defer a.mu.Unlock()
+3
View File
@@ -41,6 +41,9 @@ func (m *Mock) SyncTenantStatus(_ context.Context, slug, status string) error {
func (m *Mock) Health(_ context.Context) error { return nil }
// ServiceToken returns a fixed token so provisioning requests carry a bearer.
func (m *Mock) ServiceToken(_ context.Context) (string, error) { return "mock-service-token", nil }
func (m *Mock) CreateOrgAndInvite(_ context.Context, in InviteInput) (*InviteResult, error) {
m.mu.Lock()
defer m.mu.Unlock()
+8 -1
View File
@@ -370,7 +370,14 @@ func (s *Server) provisionProduct(ctx context.Context, r *http.Request, t *store
"id": t.ID, "name": t.Name, "slug": t.Slug, "plan": t.Plan,
"product": p.Key, "config": tp.Config, "expires_at": tp.ExpiresAt, "contract_version": "2.0",
}
if err := product.ProvisionAt(ctx, url, payload, nil, 10*time.Second); err != nil {
auth := func(ctx context.Context) (string, error) {
tok, err := s.Keycloak.ServiceToken(ctx)
if err != nil || tok == "" {
return "", err
}
return "Bearer " + tok, nil
}
if err := product.ProvisionAt(ctx, url, payload, auth, 10*time.Second); err != nil {
s.emitAudit(ctx, r, store.AuditEvent{
TenantID: t.ID, Action: "product.provision_failed", TargetID: p.Key, TargetType: "product",
Metadata: map[string]interface{}{"url": url, "err": err.Error()},
+1
View File
@@ -0,0 +1 @@
UPDATE products SET provision_urls = '{}'::jsonb WHERE key IN ('pruefwerk', 'firmwerk');
+4
View File
@@ -0,0 +1,4 @@
-- M-MIG-8: the registry provisions tenants at the products' platform endpoints
-- (PRODUCT_INTEGRATION_SPEC 2.0 §4.1) with its own service token.
UPDATE products SET provision_urls = '{"stage": "https://pruefwerk-stage.breakpilot.com/api/v1/platform/tenants/{id}/provision", "prod": "https://pruefwerk.breakpilot.com/api/v1/platform/tenants/{id}/provision"}'::jsonb WHERE key = 'pruefwerk';
UPDATE products SET provision_urls = '{"stage": "https://firmwerk-stage.breakpilot.com/api/v1/platform/tenants/{id}/provision", "prod": "https://firmwerk.breakpilot.com/api/v1/platform/tenants/{id}/provision"}'::jsonb WHERE key = 'firmwerk';