2026-02-20 17:56:25 -08:00
---
title: Harden Zot Registry
2026-04-11 17:11:56 -07:00
modified: 2026-04-11
2026-02-20 17:56:25 -08:00
tags:
- how-to
- zot
- registry
- security
---
# Harden Zot Registry
2026-02-21 15:32:34 -08:00
OIDC + API key authentication on zot with anonymous pull preserved, and tag immutability enforced server-side via accessControl. Completed as a C2 Mikado goal across PRs #236 and #237 .
2026-02-20 17:56:25 -08:00
2026-02-21 12:20:29 -08:00
## What Was Done
2026-02-20 17:56:25 -08:00
2026-02-21 12:20:29 -08:00
Updated `ansible/roles/zot/templates/config.json.j2` with:
2026-02-20 17:56:25 -08:00
2026-02-21 15:32:34 -08:00
1. * * `http.auth.openid` ** — OIDC provider pointing to Authentik (`authentik.ops.eblu.me` )
2026-02-21 12:20:29 -08:00
2. * * `http.auth.apikey: true` ** — API key generation for CI service accounts
3. * * `http.accessControl` ** — three-tier policy:
2026-02-21 08:05:16 -08:00
- `anonymousPolicy: ["read"]` — anyone can pull
- `artifact-workloads` group: `["read", "create"]` — CI can push new tags but cannot overwrite or delete (immutable tags)
2026-02-21 12:20:29 -08:00
- `admins` group: `["read", "create", "update", "delete"]` — break-glass
4. * * `http.externalUrl` ** — `https://registry.ops.eblu.me` for OIDC callback redirects
2026-02-21 15:32:34 -08:00
5. * * `accessControl.metrics.users: [""]` ** — allows anonymous Prometheus/Alloy scraping
2026-02-21 08:05:16 -08:00
2026-02-20 17:56:25 -08:00
## Key Files
| File | Purpose |
|------|---------|
2026-02-21 12:20:29 -08:00
| `ansible/roles/zot/templates/config.json.j2` | Zot config with auth + access control |
| `ansible/roles/zot/defaults/main.yml` | OIDC issuer and external URL variables |
| `ansible/roles/zot/templates/oidc-credentials.json.j2` | OIDC client credentials |
2026-04-11 17:11:56 -07:00
| `src/blumeops/main.py` | `publish()` with registry auth |
2026-02-21 12:20:29 -08:00
| `.forgejo/workflows/build-container.yaml` | Dagger push with API key |
| `.forgejo/workflows/build-container-nix.yaml` | Skopeo push with API key |
2026-02-20 17:56:25 -08:00
2026-02-21 15:32:34 -08:00
## Verified
2026-02-20 17:56:25 -08:00
2026-02-21 15:32:34 -08:00
- [x] Anonymous pull works (pull-through cache on gilbert)
- [x] Unauthenticated push fails (401)
- [x] OIDC browser login works (redirect to Authentik and back)
- [x] API key push works (zot-ci API key)
- [x] CI push succeeds (Dagger and Nix/skopeo paths)
- [x] Pull-through caching still works
- [x] Metrics endpoint accessible without auth
- [x] `mise run services-check` passes
2026-02-20 17:56:25 -08:00
## Related
2026-02-21 12:20:29 -08:00
- [[register-zot-oidc-client]] — OIDC client registration in Authentik
- [[wire-ci-registry-auth]] — CI push path wiring
2026-02-21 15:32:34 -08:00
- [[enforce-tag-immutability]] — Server-side via accessControl
2026-02-21 12:20:29 -08:00
- [[adopt-commit-based-container-tags]] — Commit-SHA-based image tags