feat: run Artifact Registry's IAM auth flow without edit mode

What

Runs Artifact Registry's real auth flow — a GitLab-issued JWT, IAM's relationship store, GLAZ's policy decision — with every service deployed. It previously required running GitLab in edit mode.

Three pieces make that work:

  • TLS in front of IAM. Deployed Rails refuses a plaintext IAM channel, so charts/iam-data-access-tls-proxy terminates TLS in front of iam and both callers dial that. The leaf is a cert-manager Certificate from the existing caproni-ca issuer.
  • Feature flags in the right database. A post-install hook Job (charts/artifact-registry-iam-bootstrap) covers gitlabhq_production; the existing edit-mode hook still covers gitlabhq_development.
  • AR's IAM service token on first boot. charts/artifact-registry-iam-token mirrors the GitLab-owned secret into AR's namespace, so scripts/configure-artifact-registry-iam-token.sh is no longer needed.

The helpers that drive this flow are not Artifact Registry's: minting a JWT, granting a role and creating a test user now live in scripts/lib/gitlab-rig.sh and scripts/lib/iam-auth.sh, so the next service to join IAM names its own audience and deployer instead of forking them. scripts/smoke-iam-auth.sh proves the flow end to end — anonymous refused, JWT accepted, ungranted caller denied, then granted and round-tripping an artifact — and CI runs it on a real rig as integration artifact-registry-with-iam.

Fixes

  • AR and iam both fetched /oauth/discovery/keys, which never holds the token's kid, so every token was rejected with a 401. Now /-/cloud_connector/keys.
  • global.appConfig.iamDataAccessService moved out of values/gitlab.yaml, which applied it to rigs with no iam deployed.
  • secretEnvFrom moved to the top level, where Fairway reads it.
  • A namespace's entity_id is the organization's own UUID, read from Rails. This supersedes the slug hash that landed in df67f2a: both satisfy AR's UUIDv7 check, but only the real UUID matches the organization the namespace belongs to. Anchors are immutable, so a rig seeded under the hash needs AR_ORG_ID= or a fresh namespace; the seeder now says so instead of failing with a bare 409.
  • smoke-rig.sh ran the bootstrap-token round-trip even on a token_exchange rig, where it cannot authenticate. It now picks the round-trip that matches the mode.
  • collect-rig-logs.sh selected app.kubernetes.io/name=iam, which matches no pod, so IAM logs were never collected. It now also captures the TLS bridge and the feature-flag hook.

Scripts

Script Scope
scripts/lib/gitlab-rig.sh any rig: toolbox exec, name and UUID validation
scripts/lib/iam-auth.sh any IAM consumer: auth mode, JWT minting, role grants
scripts/lib/ar-auth.sh AR only: its namespace anchor, namespaces API, bootstrap token
scripts/mint-jwt.sh prints a token_exchange JWT; no PAT, no feature flag
scripts/bootstrap-test-user.sh a plain organization member to test authorization as
scripts/grant-ar-role.sh resolves an AR slug to a resource id, then grants
scripts/seed-ar-namespace.sh mode-aware seeding

Each resolves its own credential from the composed config; none needs a personal access token. The parameters a second consumer overrides are listed in docs/artifact-registry.md.

Design

docs/artifact-registry.md's "GitLab must be in edit mode" section is rewritten.

Testing

scripts/smoke-iam-auth.sh is the automated check, wired into smoke-rig.sh and run by the new integration artifact-registry-with-iam job, which triggers only when AR or the IAM stack changes. Locally it was run against a token_exchange rig repeatedly, including with a never-granted user so the denial is proved rather than assumed; it refuses to run at all if the target repository is public, since a public repository skips the GLAZ check and would pass while proving nothing.

Also verified: scripts/check-config.sh, shellcheck and glab ci lint pass, the charts render, and the TLS bridge was checked end to end in a scratch namespace — cert issued by caproni-ca, Verify return code: 0 (ok) with ALPN h2, and a gRPC client reaching Envoy.

Known issue

iam v1.40.x intermittently segfaults in cel-go's parser while serving Read/WriteRelationships. It is a race and succeeds on retry, surfacing as "The Artifact Registry service is unavailable."

🤖 Generated with Claude Code

Edited by Shweta Sharma

Merge request reports

Loading
Loading