feat(catalogue,helm,ci): add private OCI auth, offline catalogue mirror, CI image/SBOM, metrics config, and OpenShift overlay (#2153)

This commit is contained in:
sam committed 2026-11-27 22:13:30 +11:00
1 parent dd38d93a29
commit fdfcbab4bd
23 files changed
+1095 -12

No files matched your search

+48
View File
@@ -167,6 +167,54 @@ jobs:
cache-from: type=gha,scope=archie-agent
cache-to: type=gha,mode=max,scope=archie-agent
archie-image:
needs: [plan, gate]
outputs:
archie_digest: ${{ steps.archie.outputs.digest }}
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f
with:
name: archie-ci
cleanup: false
- name: Log in to the Gitea registry
run: echo "${{ secrets.DEPLOY_TOKEN }}" | docker login git.catlow.cloud -u "${{ github.actor }}" --password-stdin
- name: Build and push archie
id: archie
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8
with:
context: .
file: Dockerfile.archie
push: true
sbom: true
provenance: mode=max
tags: |
git.catlow.cloud/sam/archie:v${{ needs.plan.outputs.archied_version }}
git.catlow.cloud/sam/archie:sha-${{ needs.plan.outputs.sha }}
build-args: |
VERSION=${{ needs.plan.outputs.archied_version }}
REVISION=${{ needs.plan.outputs.sha }}
cache-from: type=gha,scope=archie
cache-to: type=gha,mode=max,scope=archie
- name: Sign image with cosign
if: env.COSIGN_PRIVATE_KEY != ''
env:
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
run: |
if command -v cosign >/dev/null 2>&1; then
cosign sign --yes --key env://COSIGN_PRIVATE_KEY "git.catlow.cloud/sam/archie@${{ steps.archie.outputs.digest }}"
else
echo "::warning::cosign binary not installed on runner; skipping signature"
fi
dist-zip:
needs: [plan, gate, archied-image, agent-image]
runs-on: self-hosted
+5 -1
View File
@@ -36,7 +36,7 @@ func run() error {
newIdentity := flag.Bool("new-age-identity", false, "print a new age identity for age_identity and exit")
showVersion := buildinfo.RegisterVersionFlag("archie")
flag.Usage = func() {
_, _ = fmt.Fprintln(flag.CommandLine.Output(), "usage: archie [flags]\n archie migrate apply database migrations and runtime grants\n archie bootstrap idempotently provision initial owner and SSO settings\n archie rekey rotate age sealing identities in one transaction\n archie bundle validate, export, diff, or apply promotion bundles\n archie openapi print the API's OpenAPI document")
_, _ = fmt.Fprintln(flag.CommandLine.Output(), "usage: archie [flags]\n archie migrate apply database migrations and runtime grants\n archie bootstrap idempotently provision initial owner and SSO settings\n archie rekey rotate age sealing identities in one transaction\n archie bundle validate, export, diff, or apply promotion bundles\n archie catalogue generate keys or mirror extension catalogues offline\n archie openapi print the API's OpenAPI document")
flag.PrintDefaults()
}
flag.Parse()
@@ -65,6 +65,10 @@ func run() error {
return exitCodeError(code)
}
return nil
case "catalogue":
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
return archie.RunCatalogueCLI(ctx, flag.Args()[1:], os.Stdout)
case "openapi":
doc, err := archie.Document()
if err != nil {
@@ -76,3 +76,26 @@ Migration secret name.
{{- define "archie.migrateSecretName" -}}
{{- default .Values.secrets.existingSecret .Values.migrate.existingSecret }}
{{- end }}
{{/*
Render a map to YAML while omitting keys whose value is null (used so OpenShift
restricted-v2 overlays can unset runAsUser, runAsGroup, and fsGroup cleanly).
*/}}
{{- define "archie.compactYaml" -}}
{{- $out := dict -}}
{{- range $k, $v := . -}}
{{- if not (kindIs "invalid" $v) -}}
{{- if kindIs "map" $v -}}
{{- $sub := include "archie.compactYaml" $v -}}
{{- if $sub -}}
{{- $_ := set $out $k (fromYaml $sub) -}}
{{- end -}}
{{- else -}}
{{- $_ := set $out $k $v -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- if $out -}}
{{- toYaml $out -}}
{{- end -}}
{{- end }}
@@ -7,6 +7,9 @@ metadata:
data:
config.toml: |
listen = {{ .Values.config.listen | quote }}
{{- if .Values.metrics.enabled }}
metrics_listen = {{ printf "0.0.0.0:%v" .Values.metrics.port | quote }}
{{- end }}
state_dir = {{ .Values.config.stateDir | quote }}
shutdown_grace = {{ .Values.config.shutdownGrace | quote }}
{{- if .Values.config.ageBackupRecipients }}
@@ -25,6 +28,9 @@ data:
{{- if .Values.config.catalogue.publicKey }}
public_key = {{ .Values.config.catalogue.publicKey | quote }}
{{- end }}
{{- if .Values.config.catalogue.authSecret }}
auth_file = "/run/secrets/archie-catalogue/config.json"
{{- end }}
[extensions]
require_remote = {{ .Values.config.extensions.requireRemote }}
@@ -25,8 +25,10 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with (include "archie.compactYaml" .Values.podSecurityContext) }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- . | nindent 8 }}
{{- end }}
containers:
- name: bootstrap
image: {{ include "archie.image" . }}
@@ -37,8 +39,10 @@ spec:
- "-spec"
- "/etc/archie/bootstrap.toml"
- "bootstrap"
{{- with (include "archie.compactYaml" .Values.securityContext) }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
{{- . | nindent 12 }}
{{- end }}
env:
- name: HOME
value: "/tmp"
@@ -31,8 +31,10 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with (include "archie.compactYaml" .Values.podSecurityContext) }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- . | nindent 8 }}
{{- end }}
containers:
- name: bundle-sync
image: {{ include "archie.image" . }}
@@ -55,8 +57,10 @@ spec:
{{- if .Values.bundleSync.dryRun }}
- "--dry-run"
{{- end }}
{{- with (include "archie.compactYaml" .Values.securityContext) }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
{{- . | nindent 12 }}
{{- end }}
env:
- name: HOME
value: "/tmp"
@@ -25,8 +25,10 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with (include "archie.compactYaml" .Values.podSecurityContext) }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- . | nindent 8 }}
{{- end }}
containers:
- name: migrate
image: {{ include "archie.image" . }}
@@ -35,8 +37,10 @@ spec:
- "-config"
- ""
- "migrate"
{{- with (include "archie.compactYaml" .Values.securityContext) }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
{{- . | nindent 12 }}
{{- end }}
env:
- name: HOME
value: "/tmp"
@@ -31,8 +31,10 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with (include "archie.compactYaml" .Values.podSecurityContext) }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- . | nindent 8 }}
{{- end }}
containers:
- name: archie
image: {{ include "archie.image" . }}
@@ -40,8 +42,10 @@ spec:
args:
- "-config"
- "/etc/archie/config.toml"
{{- with (include "archie.compactYaml" .Values.securityContext) }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
{{- . | nindent 12 }}
{{- end }}
ports:
- name: http
containerPort: 8080
@@ -130,6 +134,11 @@ spec:
mountPath: {{ .Values.config.extensions.tls.mountPath }}
readOnly: true
{{- end }}
{{- if .Values.config.catalogue.authSecret }}
- name: catalogue-auth
mountPath: /run/secrets/archie-catalogue
readOnly: true
{{- end }}
volumes:
- name: config
configMap:
@@ -172,6 +181,15 @@ spec:
secretName: {{ .Values.config.extensions.tls.existingSecret }}
defaultMode: 0400
{{- end }}
{{- if .Values.config.catalogue.authSecret }}
- name: catalogue-auth
secret:
secretName: {{ .Values.config.catalogue.authSecret }}
defaultMode: 0400
items:
- key: {{ .Values.config.catalogue.authSecretKey }}
path: config.json
{{- end }}
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
volumeClaimTemplates:
- metadata:
@@ -0,0 +1,24 @@
# OpenShift restricted-v2 SCC overlay: let OpenShift allocate namespace UIDs
# and GID 0 rather than pinning UID/GID 65532.
# Example:
# helm upgrade --install archie deployments/helm/archie \
# -f deployments/helm/archie/values-prod.yaml \
# -f deployments/helm/archie/values-openshift.yaml
podSecurityContext:
runAsNonRoot: true
runAsUser: null
runAsGroup: null
fsGroup: null
fsGroupChangePolicy: OnRootMismatch
seccompProfile:
type: RuntimeDefault
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: null
capabilities:
drop:
- ALL
+4
View File
@@ -55,6 +55,9 @@ config:
location: ""
publicKey: ""
disableAutoUpdate: true
# Optional Secret containing Docker config.json for private OCI catalogue registries.
authSecret: ""
authSecretKey: "config.json"
extensions:
# Kubernetes restricted PSS forbids CLONE_NEWUSER namespaces; require remote gRPC+mTLS extensions.
requireRemote: true
@@ -200,6 +203,7 @@ service:
annotations: {}
metrics:
enabled: true
port: 9090
path: "/metrics"
serviceMonitor:
@@ -69,6 +69,23 @@ In Kubernetes, run extensions as separate Pods or sidecars under `restricted` Po
In Docker Compose and VM hosts, `LocalNamespaceRuntime` confines each extension binary in its own user and network namespace behind an allow-list forward proxy (`modules/connectors/internal/egress/tunnel.go`). The tunnel enforces Archie's host allow-list and loopback checks before chaining allowed traffic through `HTTPS_PROXY`.
### OpenShift `restricted-v2` SCC
OpenShift's default `restricted-v2` security context rejects pinned `runAsUser`, `runAsGroup`, and `fsGroup` values because it assigns UIDs per namespace. Add [values-openshift.yaml](../../deployments/helm/archie/values-openshift.yaml) alongside `values-prod.yaml` to omit those numeric IDs while keeping `runAsNonRoot: true`, `allowPrivilegeEscalation: false`, and a read-only root filesystem.
## Private OCI and Air-Gapped Catalogues
Private OCI registries authenticate through `[catalogue]` in `config.toml` or container environment variables:
- **Docker config file:** Set `catalogue.auth_file` (`ARCHIE_CATALOGUE_AUTH_FILE`) or set `config.catalogue.authSecret` in Helm to mount a registry `config.json` Secret.
- **Direct credentials:** Set `catalogue.username` and `catalogue.password` via `ARCHIE_CATALOGUE_USERNAME` and `ARCHIE_CATALOGUE_PASSWORD_FILE`.
In air-gapped stages, mirror a verified catalogue to local storage and re-sign it with an internal Ed25519 key:
1. Generate an internal signing keypair with `archie catalogue keygen`.
2. Download, verify, and re-sign the catalogue and binaries with `archie catalogue mirror -to /var/lib/archie/mirror -sign-key-file /etc/archie/mirror.key`.
3. Transfer the mirror directory into the isolated environment and point `[catalogue]` `location` and `public_key` at the mirrored `catalogue.json` and internal public key.
## Probes, Graceful Drain, and High Availability
`cmd/archie` exposes three health endpoints (`internal/platform/health/health.go`):
+145
View File
@@ -0,0 +1,145 @@
package archie
import (
"context"
json "encoding/json/v2"
"errors"
"flag"
"fmt"
"io"
"os"
"strings"
"github.com/samcharles93/archie-core/modules/connectors"
)
// RunCatalogueCLI dispatches `archie catalogue <keygen|mirror>`.
func RunCatalogueCLI(ctx context.Context, args []string, stdout io.Writer) error {
if stdout == nil {
stdout = os.Stdout
}
if len(args) == 0 {
return errors.New("usage: archie catalogue <keygen|mirror> [flags]")
}
switch args[0] {
case "keygen":
return runCatalogueKeygen(args[1:], stdout)
case "mirror":
return runCatalogueMirror(ctx, args[1:], stdout)
default:
return fmt.Errorf("unknown catalogue subcommand %q", args[0])
}
}
func runCatalogueKeygen(args []string, stdout io.Writer) error {
fs := flag.NewFlagSet("catalogue keygen", flag.ContinueOnError)
asJSON := fs.Bool("json", false, "emit output as JSON")
if err := fs.Parse(args); err != nil {
return err
}
priv, pub, err := connectors.GenerateCatalogueKeypair()
if err != nil {
return err
}
if *asJSON {
out, err := json.Marshal(struct {
PrivateKey string `json:"private_key"`
PublicKey string `json:"public_key"`
}{PrivateKey: priv, PublicKey: pub})
if err != nil {
return err
}
_, err = fmt.Fprintln(stdout, string(out))
return err
}
_, err = fmt.Fprintf(stdout, "private_key: %s\npublic_key: %s\n", priv, pub)
return err
}
func runCatalogueMirror(ctx context.Context, args []string, stdout io.Writer) error {
defaultLoc, defaultKey := connectors.DefaultCatalogueSource()
fs := flag.NewFlagSet("catalogue mirror", flag.ContinueOnError)
from := fs.String("from", defaultLoc, "upstream OCI repository, HTTPS URL, or local path")
pubKey := fs.String("public-key", defaultKey, "base64 Ed25519 public key for upstream verification")
dest := fs.String("to", "", "destination directory for the offline mirror")
signKeyFile := fs.String("sign-key-file", "", "path to base64 Ed25519 private signing key (or ARCHIE_CATALOGUE_SIGN_KEY_FILE)")
authFile := fs.String("auth-file", "", "path to Docker config.json for private OCI auth (or ARCHIE_CATALOGUE_AUTH_FILE)")
username := fs.String("username", "", "OCI registry username (or ARCHIE_CATALOGUE_USERNAME)")
passwordFile := fs.String("password-file", "", "path to OCI registry password (or ARCHIE_CATALOGUE_PASSWORD_FILE)")
asJSON := fs.Bool("json", false, "emit output as JSON")
if err := fs.Parse(args); err != nil {
return err
}
if strings.TrimSpace(*dest) == "" {
return errors.New("-to destination directory is required")
}
signKey, _, err := envOrFile("ARCHIE_CATALOGUE_SIGN_KEY", "ARCHIE_CATALOGUE_SIGN_KEY_FILE")
if err != nil {
return err
}
if *signKeyFile != "" {
raw, err := os.ReadFile(*signKeyFile) //nolint:gosec // operator-configured signing key path
if err != nil {
return fmt.Errorf("read sign key file %s: %w", *signKeyFile, err)
}
signKey = strings.TrimSpace(string(raw))
}
if signKey == "" {
return errors.New("a signing private key is required (-sign-key-file or ARCHIE_CATALOGUE_SIGN_KEY_FILE)")
}
regAuth, err := loadMirrorAuth(*username, *passwordFile, *authFile)
if err != nil {
return err
}
res, err := connectors.MirrorCatalogue(ctx, connectors.MirrorOptions{
From: *from,
VerifyPublicKey: *pubKey,
DestDir: *dest,
SignPrivateKey: signKey,
Auth: regAuth,
})
if err != nil {
return err
}
if *asJSON {
out, err := json.Marshal(res)
if err != nil {
return err
}
_, err = fmt.Fprintln(stdout, string(out))
return err
}
_, err = fmt.Fprintf(stdout, "mirrored %d extension artifact(s) to %s\n", len(res.Mirrored), res.CataloguePath)
return err
}
func loadMirrorAuth(username, passwordFile, authFile string) (connectors.CatalogueAuth, error) {
if username == "" {
username = strings.TrimSpace(os.Getenv("ARCHIE_CATALOGUE_USERNAME"))
}
var password string
if passwordFile != "" {
raw, err := os.ReadFile(passwordFile) //nolint:gosec // operator-configured password file path
if err != nil {
return connectors.CatalogueAuth{}, fmt.Errorf("read password file %s: %w", passwordFile, err)
}
password = strings.TrimSpace(string(raw))
} else {
var err error
password, _, err = envOrFile("ARCHIE_CATALOGUE_PASSWORD", "ARCHIE_CATALOGUE_PASSWORD_FILE")
if err != nil {
return connectors.CatalogueAuth{}, err
}
}
if authFile == "" {
authFile = strings.TrimSpace(os.Getenv("ARCHIE_CATALOGUE_AUTH_FILE"))
}
return connectors.CatalogueAuth{
Username: username,
Password: password,
AuthFile: authFile,
}, nil
}
+19
View File
@@ -58,6 +58,19 @@ type CatalogueConfig struct {
Location string `toml:"location"`
PublicKey string `toml:"public_key"`
DisableAutoUpdate bool `toml:"disable_auto_update"`
Username string `toml:"username"`
Password string `toml:"password"`
AuthFile string `toml:"auth_file"`
}
// Auth returns the OCI registry authentication settings configured for the
// extension catalogue.
func (c CatalogueConfig) Auth() connectors.CatalogueAuth {
return connectors.CatalogueAuth{
Username: c.Username,
Password: c.Password,
AuthFile: c.AuthFile,
}
}
// ExtensionsConfig configures remote gRPC+mTLS extension endpoints for
@@ -262,6 +275,9 @@ func applyEnv(cfg *Config) error {
{envKey: "ARCHIE_SHUTDOWN_GRACE", target: &cfg.ShutdownGraceRaw},
{envKey: "ARCHIE_CATALOGUE_LOCATION", target: &cfg.Catalogue.Location},
{envKey: "ARCHIE_CATALOGUE_PUBLIC_KEY", target: &cfg.Catalogue.PublicKey},
{envKey: "ARCHIE_CATALOGUE_USERNAME", target: &cfg.Catalogue.Username},
{envKey: "ARCHIE_CATALOGUE_PASSWORD", fileKey: "ARCHIE_CATALOGUE_PASSWORD_FILE", target: &cfg.Catalogue.Password},
{envKey: "ARCHIE_CATALOGUE_AUTH_FILE", target: &cfg.Catalogue.AuthFile},
{envKey: "ARCHIE_EXTENSIONS_CA_FILE", target: &cfg.Extensions.CAFile},
{envKey: "ARCHIE_EXTENSIONS_CERT_FILE", target: &cfg.Extensions.CertFile},
{envKey: "ARCHIE_EXTENSIONS_KEY_FILE", target: &cfg.Extensions.KeyFile},
@@ -347,6 +363,9 @@ func (c Config) validate() error {
if (c.Catalogue.Location == "") != (c.Catalogue.PublicKey == "") {
errs = append(errs, errors.New("catalogue.location and catalogue.public_key must be set together"))
}
if (c.Catalogue.Username != "") != (c.Catalogue.Password != "") {
errs = append(errs, errors.New("catalogue.username and catalogue.password must be set together"))
}
return errors.Join(errs...)
}
+29
View File
@@ -114,6 +114,35 @@ func TestLoadConfigRuntimeAndEnvFiles(t *testing.T) {
if _, err := LoadConfig(""); err == nil || !strings.Contains(err.Error(), "not both") {
t.Fatalf("expected ambiguity error, got %v", err)
}
t.Run("catalogue auth env and file overrides", func(t *testing.T) {
passFile := filepath.Join(dir, "registry_pass")
authFile := filepath.Join(dir, "config.json")
if err := os.WriteFile(passFile, []byte("oci-secret\n"), 0o600); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(authFile, []byte(`{"auths":{}}`), 0o600); err != nil {
t.Fatal(err)
}
t.Setenv("ARCHIE_DATABASE_URL", "")
t.Setenv("ARCHIE_CATALOGUE_USERNAME", "oci-bot")
t.Setenv("ARCHIE_CATALOGUE_PASSWORD_FILE", passFile)
t.Setenv("ARCHIE_CATALOGUE_AUTH_FILE", authFile)
got, err := LoadConfig("")
if err != nil {
t.Fatalf("LoadConfig with catalogue auth: %v", err)
}
if got.Catalogue.Username != "oci-bot" || got.Catalogue.Password != "oci-secret" || got.Catalogue.AuthFile != authFile {
t.Fatalf("unexpected catalogue auth config: %+v", got.Catalogue)
}
t.Setenv("ARCHIE_CATALOGUE_PASSWORD", "")
t.Setenv("ARCHIE_CATALOGUE_PASSWORD_FILE", "")
if _, err := LoadConfig(""); err == nil || !strings.Contains(err.Error(), "must be set together") {
t.Fatalf("expected paired registry credential error, got %v", err)
}
})
}
// TestLoadMigrateConfigRequiresOnlyDatabaseRoles guards migration jobs running
+5
View File
@@ -322,6 +322,11 @@ func configureConnectors(conns *connectors.Module, cfg Config) error {
return fmt.Errorf("default catalogue: %w", err)
}
}
if authCfg := cfg.Catalogue.Auth(); !authCfg.Empty() {
if err := conns.UseCatalogueAuth(authCfg); err != nil {
return fmt.Errorf("catalogue auth: %w", err)
}
}
if cfg.Extensions.RequireRemote || len(cfg.Extensions.Remote) > 0 {
if err := conns.UseRemotes(connectors.RemoteConfig{
RequireRemote: cfg.Extensions.RequireRemote,
+63
View File
@@ -0,0 +1,63 @@
package connectors
import (
"context"
"fmt"
"github.com/samcharles93/archie-core/modules/connectors/internal/catalogue"
)
// MirrorOptions configures offline mirroring of a signed extension catalogue.
type MirrorOptions struct {
From string
VerifyPublicKey string
DestDir string
SignPrivateKey string
Auth CatalogueAuth
}
// MirrorResult describes the signed offline catalogue produced by MirrorCatalogue.
type MirrorResult = catalogue.MirrorResult
// MirroredExtension describes one verified extension binary written to a mirror.
type MirroredExtension = catalogue.MirroredExtension
// DefaultCatalogueSource returns the built-in Archipelago catalogue location
// and base64 Ed25519 trust root.
func DefaultCatalogueSource() (location, publicKey string) {
return archipelagoLocation, archipelagoKey
}
// GenerateCatalogueKeypair generates an Ed25519 signing keypair encoded as
// base64 private seed and base64 public key.
func GenerateCatalogueKeypair() (seedBase64, pubBase64 string, err error) {
return catalogue.GenerateKeypair()
}
// MirrorCatalogue verifies the upstream catalogue, downloads all extension
// artifacts, and writes a re-signed offline mirror into opts.DestDir.
func MirrorCatalogue(ctx context.Context, opts MirrorOptions) (MirrorResult, error) {
from := opts.From
pubStr := opts.VerifyPublicKey
if from == "" {
from = archipelagoLocation
}
if pubStr == "" {
pubStr = archipelagoKey
}
verifyKey, err := catalogue.ParseKey(pubStr)
if err != nil {
return MirrorResult{}, fmt.Errorf("upstream public key: %w", err)
}
signKey, err := catalogue.ParsePrivateKey(opts.SignPrivateKey)
if err != nil {
return MirrorResult{}, fmt.Errorf("mirror signing key: %w", err)
}
credFn, err := opts.Auth.CredentialFunc()
if err != nil {
return MirrorResult{}, fmt.Errorf("registry auth: %w", err)
}
f := catalogue.NewFetcher("")
f.Auth = credFn
return f.MirrorToDir(ctx, from, opts.DestDir, verifyKey, signKey)
}
@@ -0,0 +1,142 @@
package catalogue
import (
"context"
"encoding/base64"
json "encoding/json/v2"
"errors"
"fmt"
"net/url"
"os"
"path/filepath"
"strings"
"oras.land/oras-go/v2/registry/remote/auth"
)
// RegistryAuth configures authentication for private OCI extension registries.
type RegistryAuth struct {
Username string
Password string
AuthFile string
}
// Empty reports whether no registry authentication settings are configured.
func (a RegistryAuth) Empty() bool {
return strings.TrimSpace(a.Username) == "" &&
strings.TrimSpace(a.Password) == "" &&
strings.TrimSpace(a.AuthFile) == ""
}
type dockerConfig struct {
Auths map[string]dockerAuthEntry `json:"auths"`
}
type dockerAuthEntry struct {
Auth string `json:"auth"`
Username string `json:"username"`
Password string `json:"password"`
IdentityToken string `json:"identitytoken"`
}
// CredentialFunc validates the configured authentication settings and returns
// an oras credential resolver. A zero RegistryAuth yields nil with no error.
func (a RegistryAuth) CredentialFunc() (auth.CredentialFunc, error) {
if a.Empty() {
return nil, nil
}
user := strings.TrimSpace(a.Username)
pass := a.Password
if (user != "") != (pass != "") {
return nil, errors.New("catalogue registry username and password must be set together")
}
var byHost map[string]auth.Credential
if path := strings.TrimSpace(a.AuthFile); path != "" {
var err error
byHost, err = loadDockerAuths(path)
if err != nil {
return nil, err
}
}
return func(_ context.Context, hostport string) (auth.Credential, error) {
if user != "" {
return auth.Credential{Username: user, Password: pass}, nil
}
if len(byHost) == 0 {
return auth.EmptyCredential, nil
}
key := normaliseRegistryKey(hostport)
if cred, ok := byHost[key]; ok {
return cred, nil
}
if key == "registry-1.docker.io" {
if cred, ok := byHost["index.docker.io"]; ok {
return cred, nil
}
}
return auth.EmptyCredential, nil
}, nil
}
func loadDockerAuths(path string) (map[string]auth.Credential, error) {
raw, err := os.ReadFile(filepath.Clean(path)) //nolint:gosec // operator-configured Docker auth file path
if err != nil {
return nil, fmt.Errorf("read catalogue auth file %s: %w", path, err)
}
var cfg dockerConfig
if err := json.Unmarshal(raw, &cfg); err != nil {
return nil, fmt.Errorf("parse catalogue auth file %s: %w", path, err)
}
out := make(map[string]auth.Credential, len(cfg.Auths))
for rawHost, entry := range cfg.Auths {
host := normaliseRegistryKey(rawHost)
if host == "" {
continue
}
cred, err := decodeDockerAuth(host, entry)
if err != nil {
return nil, fmt.Errorf("catalogue auth file %s: %w", path, err)
}
if cred != auth.EmptyCredential {
out[host] = cred
}
}
return out, nil
}
func decodeDockerAuth(host string, entry dockerAuthEntry) (auth.Credential, error) {
if entry.Username != "" || entry.Password != "" {
return auth.Credential{Username: entry.Username, Password: entry.Password}, nil
}
if entry.Auth != "" {
decoded, err := base64.StdEncoding.DecodeString(strings.TrimSpace(entry.Auth))
if err != nil {
return auth.EmptyCredential, fmt.Errorf("registry %s: invalid base64 auth: %w", host, err)
}
user, pass, ok := strings.Cut(string(decoded), ":")
if !ok {
return auth.EmptyCredential, fmt.Errorf("registry %s: auth entry must be username:password", host)
}
return auth.Credential{Username: user, Password: pass}, nil
}
if entry.IdentityToken != "" {
return auth.Credential{RefreshToken: entry.IdentityToken}, nil
}
return auth.EmptyCredential, nil
}
func normaliseRegistryKey(raw string) string {
key := strings.TrimSpace(raw)
if key == "" {
return ""
}
if strings.Contains(key, "://") {
if u, err := url.Parse(key); err == nil && u.Host != "" {
return strings.ToLower(u.Host)
}
}
host, _, _ := strings.Cut(key, "/")
return strings.ToLower(strings.TrimSpace(host))
}
@@ -0,0 +1,164 @@
package catalogue
import (
"crypto/ed25519"
"encoding/base64"
"fmt"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"strconv"
"strings"
"testing"
digest "github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"oras.land/oras-go/v2/registry/remote/auth"
)
func TestRegistryAuthCredentialFunc(t *testing.T) {
dir := t.TempDir()
authJSON := filepath.Join(dir, "config.json")
encoded := base64.StdEncoding.EncodeToString([]byte("robot:secret-pass"))
if err := os.WriteFile(authJSON, []byte(`{
"auths": {
"https://registry.internal:5000/v2/": {"auth": "`+encoded+`"},
"ghcr.io": {"username": "gh-user", "password": "gh-token"},
"https://index.docker.io/v1/": {"username": "hub-user", "password": "hub-pass"}
}
}`), 0o600); err != nil {
t.Fatal(err)
}
badJSON := filepath.Join(dir, "bad.json")
if err := os.WriteFile(badJSON, []byte(`{not json`), 0o600); err != nil {
t.Fatal(err)
}
t.Run("empty config returns nil", func(t *testing.T) {
fn, err := (RegistryAuth{}).CredentialFunc()
if err != nil || fn != nil {
t.Fatalf("got (%v, %v), want (nil, nil)", fn != nil, err)
}
})
t.Run("partial static credentials fail closed", func(t *testing.T) {
if _, err := (RegistryAuth{Username: "alice"}).CredentialFunc(); err == nil {
t.Fatal("expected error for username without password")
}
if _, err := (RegistryAuth{Password: "secret"}).CredentialFunc(); err == nil {
t.Fatal("expected error for password without username")
}
})
t.Run("bad auth file fails closed", func(t *testing.T) {
if _, err := (RegistryAuth{AuthFile: badJSON}).CredentialFunc(); err == nil {
t.Fatal("expected error for invalid JSON auth file")
}
if _, err := (RegistryAuth{AuthFile: filepath.Join(dir, "missing.json")}).CredentialFunc(); err == nil {
t.Fatal("expected error for missing auth file")
}
})
t.Run("static credentials override auth file", func(t *testing.T) {
fn, err := (RegistryAuth{Username: "static", Password: "pw", AuthFile: authJSON}).CredentialFunc()
if err != nil {
t.Fatal(err)
}
got, err := fn(t.Context(), "ghcr.io")
if err != nil || got.Username != "static" || got.Password != "pw" {
t.Fatalf("got (%+v, %v), want static/pw", got, err)
}
})
t.Run("docker config lookup normalises schemes and aliases", func(t *testing.T) {
fn, err := (RegistryAuth{AuthFile: authJSON}).CredentialFunc()
if err != nil {
t.Fatal(err)
}
cases := []struct {
host string
wantUser string
wantPass string
}{
{"registry.internal:5000", "robot", "secret-pass"},
{"ghcr.io", "gh-user", "gh-token"},
{"registry-1.docker.io", "hub-user", "hub-pass"},
{"unknown.example", "", ""},
}
for _, tc := range cases {
got, err := fn(t.Context(), tc.host)
if err != nil {
t.Fatalf("%s: %v", tc.host, err)
}
if got.Username != tc.wantUser || got.Password != tc.wantPass {
t.Fatalf("%s: got (%q, %q), want (%q, %q)", tc.host, got.Username, got.Password, tc.wantUser, tc.wantPass)
}
}
if cred, _ := fn(t.Context(), "unknown.example"); cred != auth.EmptyCredential {
t.Fatalf("unmatched host returned %+v, want EmptyCredential", cred)
}
})
}
func TestReadOCISendsRegistryAuth(t *testing.T) {
key, signer, err := ed25519.GenerateKey(nil)
if err != nil {
t.Fatal(err)
}
const metadata = `apiVersion: dev.archie.package.v1
version: 1.0.0
contributes:
extensions:
- surface: guard
path: bin/hours
files:
- path: bin/hours
mode: 493`
pkg := testManifest(t, []byte("example"), map[string]string{packageDescriptor: metadata})
pin := digest.FromBytes(pkg)
wantAuth := "Basic " + base64.StdEncoding.EncodeToString([]byte("oci-user:oci-pass"))
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("Authorization") != wantAuth {
w.Header().Set("WWW-Authenticate", `Basic realm="registry"`)
w.WriteHeader(http.StatusUnauthorized)
return
}
body := fmt.Appendf(nil, `{"issued_at":"2026-11-23T00:00:00Z","packages":[{"name":"hours","surface":"guards","version":"1.0.0","reference":"%s/guards-hours","digest":"%s"}]}`, r.Host, pin)
sig := base64.StdEncoding.EncodeToString(ed25519.Sign(signer, body))
media := ocispec.MediaTypeImageManifest
var result []byte
switch r.URL.Path {
case "/v2/catalogue/manifests/latest":
result = testManifest(t, body, map[string]string{catalogueSignature: sig})
case "/v2/catalogue/blobs/" + digest.FromBytes(body).String():
media, result = "application/octet-stream", body
case "/v2/guards-hours/manifests/" + pin.String():
result = pkg
default:
http.NotFound(w, r)
return
}
w.Header().Set("Content-Type", media)
w.Header().Set("Content-Length", strconv.Itoa(len(result)))
w.Header().Set("Docker-Content-Digest", digest.FromBytes(result).String())
_, _ = w.Write(result)
}))
t.Cleanup(srv.Close)
credFn, err := (RegistryAuth{Username: "oci-user", Password: "oci-pass"}).CredentialFunc()
if err != nil {
t.Fatal(err)
}
f := NewFetcher(t.TempDir())
f.Auth = credFn
doc, err := f.Read(t.Context(), strings.TrimPrefix(srv.URL, "http://")+"/catalogue", key)
if err != nil {
t.Fatalf("Read protected OCI catalogue: %v", err)
}
if _, ok := doc.Entry("hours"); !ok {
t.Fatal("missing hours entry from protected OCI catalogue")
}
}
@@ -17,6 +17,8 @@ import (
"path/filepath"
"strings"
"time"
"oras.land/oras-go/v2/registry/remote/auth"
)
// ErrDigestMismatch means an artifact is not the binary the catalogue pins.
@@ -29,12 +31,13 @@ const (
maxDocument = 1 << 20
)
// Fetcher reads catalogues and artifacts from an https URL or from a path on
// this host.
// Fetcher reads catalogues and artifacts from an OCI repository, https URL,
// or path on this host.
type Fetcher struct {
// Dir is where verified artifacts are kept, one directory per digest.
Dir string
Client *http.Client
Auth auth.CredentialFunc
}
// NewFetcher returns a Fetcher that keeps artifacts under dir.
@@ -0,0 +1,231 @@
package catalogue
import (
"context"
"crypto/ed25519"
"crypto/rand"
"crypto/sha256"
"encoding/base64"
"encoding/hex"
json "encoding/json/v2"
"errors"
"fmt"
"io"
"os"
"path"
"path/filepath"
"strings"
"time"
)
// MirrorResult describes the signed offline catalogue written by MirrorToDir.
type MirrorResult struct {
IssuedAt time.Time `json:"issued_at"`
CataloguePath string `json:"catalogue_path"`
SignaturePath string `json:"signature_path"`
Mirrored []MirroredExtension `json:"mirrored"`
}
// MirroredExtension records one extension binary included in the offline mirror.
type MirroredExtension struct {
Name string `json:"name"`
Version string `json:"version"`
Contract string `json:"contract"`
Digest string `json:"digest"`
Artifact string `json:"artifact"`
}
// GenerateKeypair creates a fresh Ed25519 signing keypair encoded as base64
// seed (private) and base64 public key.
func GenerateKeypair() (seedBase64, pubBase64 string, err error) {
pub, priv, err := ed25519.GenerateKey(rand.Reader)
if err != nil {
return "", "", fmt.Errorf("generate Ed25519 keypair: %w", err)
}
return base64.StdEncoding.EncodeToString(priv.Seed()), base64.StdEncoding.EncodeToString(pub), nil
}
// ParsePrivateKey decodes a base64 Ed25519 private key (either a 32-byte seed
// or a 64-byte expanded private key).
func ParsePrivateKey(s string) (ed25519.PrivateKey, error) {
raw, err := base64.StdEncoding.DecodeString(strings.TrimSpace(s))
if err != nil {
return nil, errors.New("the signing key must be base64 Ed25519 material")
}
switch len(raw) {
case ed25519.SeedSize:
return ed25519.NewKeyFromSeed(raw), nil
case ed25519.PrivateKeySize:
return ed25519.PrivateKey(raw), nil
default:
return nil, errors.New("the signing key must be a 32-byte seed or 64-byte private key")
}
}
// MirrorToDir downloads and verifies a signed catalogue and all of its extension
// binaries from src, copies them into destDir, and emits a re-signed offline
// catalogue.json and catalogue.json.sig for air-gapped stages.
func (f *Fetcher) MirrorToDir(ctx context.Context, src, destDir string, verifyKey ed25519.PublicKey, signKey ed25519.PrivateKey) (MirrorResult, error) {
if destDir == "" {
return MirrorResult{}, errors.New("destination directory is required")
}
if len(verifyKey) != ed25519.PublicKeySize {
return MirrorResult{}, errors.New("valid upstream Ed25519 public key is required")
}
if len(signKey) != ed25519.PrivateKeySize {
return MirrorResult{}, errors.New("valid internal Ed25519 private key is required")
}
doc, err := f.Read(ctx, src, verifyKey)
if err != nil {
return MirrorResult{}, fmt.Errorf("read upstream catalogue %s: %w", src, err)
}
if err := os.MkdirAll(destDir, 0o750); err != nil {
return MirrorResult{}, fmt.Errorf("create mirror directory: %w", err)
}
stagingDir, err := os.MkdirTemp(destDir, ".mirror-stage-*")
if err != nil {
return MirrorResult{}, fmt.Errorf("create staging directory: %w", err)
}
defer func() { _ = os.RemoveAll(stagingDir) }()
stageFetcher := &Fetcher{Dir: stagingDir, Client: f.Client, Auth: f.Auth}
outDoc := Document{
IssuedAt: doc.IssuedAt,
Extensions: make([]Entry, 0, len(doc.Extensions)),
}
var mirrored []MirroredExtension
for _, entry := range doc.Extensions {
outEntry, items, err := stageFetcher.mirrorEntry(ctx, src, destDir, entry)
if err != nil {
return MirrorResult{}, err
}
outDoc.Extensions = append(outDoc.Extensions, outEntry)
mirrored = append(mirrored, items...)
}
body, err := json.Marshal(outDoc)
if err != nil {
return MirrorResult{}, fmt.Errorf("encode mirrored catalogue: %w", err)
}
sig := base64.StdEncoding.EncodeToString(ed25519.Sign(signKey, body))
catPath := filepath.Join(destDir, "catalogue.json")
sigPath := filepath.Join(destDir, "catalogue.json.sig")
if err := writeAtomic(catPath, body, 0o600); err != nil {
return MirrorResult{}, err
}
if err := writeAtomic(sigPath, append([]byte(sig), '\n'), 0o600); err != nil {
return MirrorResult{}, err
}
return MirrorResult{
IssuedAt: doc.IssuedAt,
CataloguePath: catPath,
SignaturePath: sigPath,
Mirrored: mirrored,
}, nil
}
func (f *Fetcher) mirrorEntry(ctx context.Context, src, destDir string, entry Entry) (Entry, []MirroredExtension, error) {
if !entryName.MatchString(entry.Name) {
return Entry{}, nil, fmt.Errorf("extension name %q is invalid", entry.Name)
}
versions := make([]Version, 0, len(entry.Versions))
mirrored := make([]MirroredExtension, 0, len(entry.Versions))
for _, v := range entry.Versions {
if err := checkMirrorSegment(v.Version); err != nil {
return Entry{}, nil, fmt.Errorf("extension %s version %q: %w", entry.Name, v.Version, err)
}
fetchedPath, digestHex, err := f.FetchVersion(ctx, entry.Name, src, v)
if err != nil {
return Entry{}, nil, fmt.Errorf("fetch %s %s: %w", entry.Name, v.Version, err)
}
relArtifact := path.Join("artifacts", entry.Name, v.Version, entry.Name)
targetPath := filepath.Join(destDir, filepath.FromSlash(relArtifact))
if err := copyVerifiedExecutable(fetchedPath, targetPath, digestHex); err != nil {
return Entry{}, nil, fmt.Errorf("stage %s %s: %w", entry.Name, v.Version, err)
}
versions = append(versions, Version{
Version: v.Version,
Artifact: relArtifact,
Digest: digestHex,
Grants: v.Grants,
Settings: v.Settings,
})
mirrored = append(mirrored, MirroredExtension{
Name: entry.Name,
Version: v.Version,
Contract: entry.Contract,
Digest: digestHex,
Artifact: relArtifact,
})
}
entry.Versions = versions
return entry, mirrored, nil
}
func checkMirrorSegment(segment string) error {
if segment == "" || segment == "." || segment == ".." || strings.ContainsAny(segment, `/\`) {
return errors.New("version contains a forbidden path segment")
}
return nil
}
func copyVerifiedExecutable(srcPath, dstPath, wantDigest string) error {
if err := os.MkdirAll(filepath.Dir(dstPath), 0o750); err != nil {
return err
}
src, err := os.Open(filepath.Clean(srcPath))
if err != nil {
return err
}
defer func() { _ = src.Close() }()
tmp, err := os.CreateTemp(filepath.Dir(dstPath), ".bin-*")
if err != nil {
return err
}
tmpName := tmp.Name()
defer func() { _ = os.Remove(tmpName) }()
h := sha256.New()
if _, err := io.Copy(io.MultiWriter(tmp, h), src); err != nil {
_ = tmp.Close()
return err
}
if err := tmp.Close(); err != nil {
return err
}
if hex.EncodeToString(h.Sum(nil)) != wantDigest {
return ErrDigestMismatch
}
if err := os.Chmod(tmpName, 0o700); err != nil { //nolint:gosec // mirrored extension binary must be executable
return err
}
return os.Rename(tmpName, dstPath)
}
func writeAtomic(dstPath string, data []byte, mode os.FileMode) error {
tmp, err := os.CreateTemp(filepath.Dir(dstPath), ".tmp-*")
if err != nil {
return fmt.Errorf("write %s: %w", dstPath, err)
}
tmpName := tmp.Name()
defer func() { _ = os.Remove(tmpName) }()
if _, err := tmp.Write(data); err != nil {
_ = tmp.Close()
return fmt.Errorf("write %s: %w", dstPath, err)
}
if err := tmp.Chmod(mode); err != nil {
_ = tmp.Close()
return fmt.Errorf("chmod %s: %w", dstPath, err)
}
if err := tmp.Close(); err != nil {
return fmt.Errorf("close %s: %w", dstPath, err)
}
if err := os.Rename(tmpName, dstPath); err != nil {
return fmt.Errorf("rename %s: %w", dstPath, err)
}
return nil
}
@@ -0,0 +1,109 @@
package catalogue
import (
"crypto/ed25519"
"crypto/rand"
"crypto/sha256"
"encoding/base64"
"encoding/hex"
"errors"
"os"
"path/filepath"
"testing"
)
func TestMirrorToDirOfflineVerification(t *testing.T) {
upPub, upPriv, err := ed25519.GenerateKey(rand.Reader)
if err != nil {
t.Fatal(err)
}
wrongPub, _, err := ed25519.GenerateKey(rand.Reader)
if err != nil {
t.Fatal(err)
}
seedB64, mirrorPubB64, err := GenerateKeypair()
if err != nil {
t.Fatal(err)
}
mirrorSignKey, err := ParsePrivateKey(seedB64)
if err != nil {
t.Fatal(err)
}
mirrorPubKey, err := ParseKey(mirrorPubB64)
if err != nil {
t.Fatal(err)
}
upstreamDir := t.TempDir()
binBytes := []byte("#!/bin/sh\necho mirrored\n")
sum := sha256.Sum256(binBytes)
digestHex := hex.EncodeToString(sum[:])
binPath := filepath.Join(upstreamDir, "vault-bin")
if err := os.WriteFile(binPath, binBytes, 0o600); err != nil {
t.Fatal(err)
}
body := []byte(`{"issued_at":"2026-11-27T00:00:00Z","extensions":[{"name":"vault","display_name":"Vault","description":"KV secrets","contract":"secretengine","versions":[{"version":"1.2.0","artifact":"vault-bin","digest":"` + digestHex + `"}]}]}`)
catFile := filepath.Join(upstreamDir, "catalogue.json")
if err := os.WriteFile(catFile, body, 0o600); err != nil {
t.Fatal(err)
}
sigFile := catFile + ".sig"
if err := os.WriteFile(sigFile, []byte(base64.StdEncoding.EncodeToString(ed25519.Sign(upPriv, body))), 0o600); err != nil {
t.Fatal(err)
}
fetcher := NewFetcher("")
mirrorDir := filepath.Join(t.TempDir(), "airgap")
// A forged upstream signature must fail closed before writing anything.
if _, err := fetcher.MirrorToDir(t.Context(), catFile, mirrorDir, mirrorPubKey, mirrorSignKey); !errors.Is(err, ErrBadSignature) {
t.Fatalf("expected ErrBadSignature with wrong key, got %v", err)
}
if _, err := os.Stat(filepath.Join(mirrorDir, "catalogue.json")); !os.IsNotExist(err) {
t.Fatalf("failed mirror created catalogue.json")
}
res, err := fetcher.MirrorToDir(t.Context(), catFile, mirrorDir, upPub, mirrorSignKey)
if err != nil {
t.Fatalf("MirrorToDir: %v", err)
}
if len(res.Mirrored) != 1 || res.Mirrored[0].Digest != digestHex {
t.Fatalf("unexpected mirror result: %+v", res)
}
// Delete the upstream source completely to prove offline independence.
if err := os.RemoveAll(upstreamDir); err != nil {
t.Fatal(err)
}
offline := NewFetcher(filepath.Join(t.TempDir(), "installed"))
doc, err := offline.Read(t.Context(), res.CataloguePath, mirrorPubKey)
if err != nil {
t.Fatalf("offline Read: %v", err)
}
entry, ok := doc.Entry("vault")
if !ok {
t.Fatal("mirrored catalogue missing vault")
}
v, ok := entry.Version("1.2.0")
if !ok {
t.Fatal("mirrored catalogue missing version 1.2.0")
}
gotPath, gotDigest, err := offline.FetchVersion(t.Context(), entry.Name, res.CataloguePath, v)
if err != nil {
t.Fatalf("offline FetchVersion: %v", err)
}
if gotDigest != digestHex {
t.Fatalf("FetchVersion digest = %q, want %q", gotDigest, digestHex)
}
gotBytes, err := os.ReadFile(gotPath) //nolint:gosec // test fixture output under t.TempDir
if err != nil || string(gotBytes) != string(binBytes) {
t.Fatalf("mirrored binary mismatch: %v", err)
}
// Ensure wrongPub still rejects against the newly signed mirror.
if _, err := offline.Read(t.Context(), res.CataloguePath, wrongPub); !errors.Is(err, ErrBadSignature) {
t.Fatalf("expected ErrBadSignature with wrong key on mirror, got %v", err)
}
}
+1 -1
View File
@@ -84,7 +84,7 @@ func (f *Fetcher) repository(loc string) (*remote.Repository, error) {
host = hostname
}
r.PlainHTTP = loopback(strings.Trim(host, "[]"))
r.Client = &auth.Client{Client: f.Client, Cache: auth.NewCache()}
r.Client = &auth.Client{Client: f.Client, Credential: f.Auth, Cache: auth.NewCache()}
return r, nil
}
+17
View File
@@ -85,6 +85,23 @@ func (m *Module) UseRemotes(cfg RemoteConfig) error {
return m.host.UseRemotes(cfg)
}
// CatalogueAuth configures private OCI registry authentication for fetching
// the extension catalogue and artifacts.
type CatalogueAuth = catalogue.RegistryAuth
// UseCatalogueAuth configures private OCI registry authentication for the
// catalogue fetcher.
func (m *Module) UseCatalogueAuth(cfg CatalogueAuth) error {
credFn, err := cfg.CredentialFunc()
if err != nil {
return err
}
m.pkgMu.Lock()
m.fetcher.Auth = credFn
m.pkgMu.Unlock()
return nil
}
// UseDefaultCatalogue overrides the fallback extension catalogue source used
// when the control plane has not set a custom location.
func (m *Module) UseDefaultCatalogue(location, publicKey string) error {