Skip to main content

Deploy Consul backends

Use the AuthCrunch v1.8.1 distribution or add github.com/greenpau/caddy-security-consul@v1.1.1 to a custom Caddy Security v1.8.1 build. The companion imports github.com/pteich/caddy-tlsconsul v1.5.0 and uses the go-authcrunch-consul v1.1.0 backend. Check both list-modules --versions and the compiled module inventory.

Configure the borrowed Consul client​

Use the caddy.storage.consul implementation bundled with the companion. It supplies the connection, KV prefix and AES key to the AuthCrunch backends. Set CONSUL_HTTP_TOKEN and configure HTTPS trust for the actual Caddy service identity. The Caddy storage module also accepts a token field. Allow the key operations required by each selected backend under the intended prefix. The Consul token and AES key must be available to the host before its secret manager reads any records.

This example selects password accounts. Supply the address and AES key at adaptation, and the portal signing key at provisioning. Give CONSUL_ADDRESS as the host and port, such as consul.example.net:8501. The TLS directives select HTTPS and keep certificate verification enabled.

{
storage consul {
address {$CONSUL_ADDRESS}
prefix caddy/authcrunch
aes_key "{$CONSUL_AES_KEY}"
tls_enabled true
tls_insecure false
}
security {
identity store consul accounts {
realm staff
timeout 3s
capacity 1000
}
authentication portal staff {
enable identity store accounts
crypto key sign-verify {env.AUTHCRUNCH_SIGNING_KEY}
}
}
}

auth.example.com {
@portal path /auth /auth/*
route @portal {
redir /auth /auth/ 308
authenticate with staff at /auth
}
}

The AES setting supplies an actual AES key of 16, 24 or 32 bytes. Keep it out of shell history and protect the adapted JSON, which can contain the value. Verify the transport, token and key handling with the pinned Caddy storage module.

For runtime key injection, omit aes_key and supply CADDY_CLUSTERING_CONSUL_AESKEY in the service environment. A nonempty value overrides the configured key. CADDY_CLUSTERING_CONSUL_PREFIX can also override the configured key prefix. Check these effective values when diagnosing an upgrade. Caddy's value_prefix setting belongs to its TLS storage. The AuthCrunch binding takes the global KV prefix and key bytes.

Provision and select records​

Use the Go companion for provisioning and trusted issuer functions. A provisioning tool sets up a Consul API client and creates a consulkv.NewBinding(client, globalPrefix, aesKey). Use the same Consul KV domain, actual AES key bytes, global prefix and backend settings as the Caddy deployment. Each backend gets its own logical handle. Closing a handle leaves the client and stored records available to its other owners. The SQLite CLI commands operate on SQLite files. Consul account creation requires a display name, a username, an email and one or more roles. The Go store normalizes username and email to lowercase and prevents collisions across both selectors. Account creation uses bcrypt with an 8–72 byte password bound. Preserve immutable account IDs and the persisted authentication epoch when restoring the KV snapshot.

Record or stateWho writes it and when
Password identityA trusted provisioning app calls identitystore.Store.Create. Use the same configured store name and realm. Subsequent credential changes update the durable version.
API keyA trusted app calls credentials.Authenticator.Issue and Revoke. Deliver issued keys privately. Requests observe current shared credentials without a reload.
TicketA trusted issuer authenticates its user and calls ticket.Provider.Issue. Compatible portal replicas consume it only with the original browser binding.
SecretA trusted app calls secrets.Client.Put. It replaces the complete typed JSON record. A successful configuration startup or reload adopts a snapshot.
Pending upstream OAuthThe selected provider writes and claims transactions. Both replicas need matching login namespace, provider configuration and bound storage address.
Managed refreshOne exclusively owned persistent AuthCrunch root writes refresh families. Preserve the same root, store and identity evidence for restart continuity.

For a secret record, give the Go client a nonempty JSON-compatible object of at most 128 top-level fields and 64 KiB of encoded data. A write replaces the entire bound record. Deleting an absent record succeeds. Make sure the next configuration can provision before deleting a required record, and verify activation with a consumer request.

For the exact options and limits, see Consul fields. For a working provisioning integration, follow the pinned Go account example.

Consul password accounts do not expose the identity-bound Profile operation interface. They also issue account IDs that the released File Vault API cannot use, even when capability discovery advertises Documents access. See File Vault identity requirements.

Size and migrate existing KV state​

Retain the Consul KV domain, global and backend prefixes, key bytes, store names, realm, record selectors and configured capacities when moving from the older per-backend Caddy imports. The new companion uses the existing encrypted payloads and complete-key binding. Secrets are keyed by record within the selected prefix. Different manager names can reference the same record.

Encrypted document backends cap plaintext at 384 KiB and also enforce category limits. Pending OAuth has separate record and index limits. Check timeouts, reserved capacity and record sizes with production-like populations. A CAS conflict that proves no write occurred can be retried within the operation budget. If the result is uncertain, reconcile state before issuing another credential. Preserve the encrypted records and key as separate protected restore inputs. Drain writers before changing any bound prefix, encryption key, capacity or storage format. Restore affected refresh state alongside its original private root directory.

Understand which requests can move​

A compatible replica can claim pending upstream OAuth state or redeem a browser-bound ticket. Completed sessions, sandbox checkpoints, downstream OIDC grants, direct-policy OAuth and cross-device flows retain their own affinity requirements. A per-instance ticket attachment does not become durable just because its ticket was durable. See state ownership.

Check a denied credential, a revoked credential, wrong-browser ticket refusal, same-root restart and your actual callback routing before enabling production traffic. An available Consul agent or successful adaptation alone only verifies part of the integration.

Agentic Prompts​

Plan a Consul deployment
Read the upstream root AGENTS.md files first:
https://github.com/greenpau/caddy-security/blob/v1.8.1/AGENTS.md
https://github.com/greenpau/go-authcrunch/blob/v1.7.1/AGENTS.md
Read applicable scoped AGENTS.md files, then the relevant skills and linked
implementation and tests under:
https://github.com/greenpau/caddy-security/tree/v1.8.1/.codex/skills
https://github.com/greenpau/go-authcrunch/tree/v1.7.1/.codex/skills
Distinguish main from the versions I deploy. Resolve disagreements using
versioned code and tests. Ask me to paste an inaccessible source. Use synthetic
or redacted inputs and flag unverified behavior.

Secondary context: https://docs.authcrunch.com/docs/operations/consul

Trace TLS and ACL configuration, actual AES key bytes, global and backend prefixes, and the matching account and portal declarations.
Provision accounts and keys
Read the upstream root AGENTS.md files first:
https://github.com/greenpau/caddy-security/blob/v1.8.1/AGENTS.md
https://github.com/greenpau/go-authcrunch/blob/v1.7.1/AGENTS.md
Read applicable scoped AGENTS.md files, then the relevant skills and linked
implementation and tests under:
https://github.com/greenpau/caddy-security/tree/v1.8.1/.codex/skills
https://github.com/greenpau/go-authcrunch/tree/v1.7.1/.codex/skills
Distinguish main from the versions I deploy. Resolve disagreements using
versioned code and tests. Ask me to paste an inaccessible source. Use synthetic
or redacted inputs and flag unverified behavior.

Secondary context: https://docs.authcrunch.com/docs/operations/consul

Explain which Go provisioning method writes accounts and keys. Identify when current credential checks observe a disablement or revocation.
Rehearse a companion upgrade
Read the upstream root AGENTS.md files first:
https://github.com/greenpau/caddy-security/blob/v1.8.1/AGENTS.md
https://github.com/greenpau/go-authcrunch/blob/v1.7.1/AGENTS.md
Read applicable scoped AGENTS.md files, then the relevant skills and linked
implementation and tests under:
https://github.com/greenpau/caddy-security/tree/v1.8.1/.codex/skills
https://github.com/greenpau/go-authcrunch/tree/v1.7.1/.codex/skills
Distinguish main from the versions I deploy. Resolve disagreements using
versioned code and tests. Ask me to paste an inaccessible source. Use synthetic
or redacted inputs and flag unverified behavior.

Secondary context: https://docs.authcrunch.com/docs/operations/consul

Inventory the identifiers and settings to preserve when replacing old per-backend imports with the new bundle. Outline a restore check without touching live state.
Diagnose a rejected peer callback
Read the upstream root AGENTS.md files first:
https://github.com/greenpau/caddy-security/blob/v1.8.1/AGENTS.md
https://github.com/greenpau/go-authcrunch/blob/v1.7.1/AGENTS.md
Read applicable scoped AGENTS.md files, then the relevant skills and linked
implementation and tests under:
https://github.com/greenpau/caddy-security/tree/v1.8.1/.codex/skills
https://github.com/greenpau/go-authcrunch/tree/v1.7.1/.codex/skills
Distinguish main from the versions I deploy. Resolve disagreements using
versioned code and tests. Ask me to paste an inaccessible source. Use synthetic
or redacted inputs and flag unverified behavior.

Secondary context: https://docs.authcrunch.com/docs/operations/consul

Check the OAuth provider digest inputs, configured Consul address, browser binding and transaction namespace. Distinguish pending recovery from a completed portal session.
Investigate a capacity incident
Read the upstream root AGENTS.md files first:
https://github.com/greenpau/caddy-security/blob/v1.8.1/AGENTS.md
https://github.com/greenpau/go-authcrunch/blob/v1.7.1/AGENTS.md
Read applicable scoped AGENTS.md files, then the relevant skills and linked
implementation and tests under:
https://github.com/greenpau/caddy-security/tree/v1.8.1/.codex/skills
https://github.com/greenpau/go-authcrunch/tree/v1.7.1/.codex/skills
Distinguish main from the versions I deploy. Resolve disagreements using
versioned code and tests. Ask me to paste an inaccessible source. Use synthetic
or redacted inputs and flag unverified behavior.

Secondary context: https://docs.authcrunch.com/docs/operations/consul

Explain the entry and byte ceilings and distinguish a definite CAS conflict from an uncertain write. Identify what evidence can be collected safely.

Source Code References​