Configuration
Purpose
Use this skill as the entry point for generating caddy-security Caddyfile
configuration. Keep the parent skill as a router: load only the domain skills
needed for the requested configuration.
The authoritative parser entry point is caddyfile.go. The global block is
security { ... }; route-level HTTP integrations reference configured objects
with authenticate with <portal> and authorize with <policy>.
Do not generate global Caddy directive-order overrides for caddy-security by
default. authenticate and authorize register their own order in
plugin_authn.go and plugin_authz.go. Only add global order directives
when debugging a proven directive-order conflict with another third-party
plugin, and explain why.
Workflow
- Identify the requested auth flow: local login, LDAP, OAuth/OIDC, SAML, API
keys, basic auth, registration, SSO app, or policy-only authorization.
- Load only the relevant
configuration-* domain skills from the Domain Map
before drafting the Caddyfile.
Load configuration-http-integrations whenever adding route-level
authenticate or authorize handlers.
Load configuration-saml-providers for saml identity provider <name>
blocks; do not substitute the SSO app skill.
Load authentication-portal-api when the request involves Portal API,
JSON login, /whoami, /beacon, or admin/server API endpoints.
- Start from the smallest valid
security app block, then add route handlers
that reference the configured portal or policy by name.
- Prefer environment placeholders or secret lookups for passwords, API keys,
client secrets, signing keys, and private material.
- Check generated syntax against the parser files and the fixtures under
testdata/caddyfile_adapt/. Use the testing-and-ci skill if validation
requires running tests or updating fixtures.
Common Shape
{
security {
local identity store localdb {
realm local
path assets/config/users.json
}
authentication portal myportal {
crypto key sign-verify {env.JWT_SHARED_KEY}
enable identity store localdb
}
authorization policy app_policy {
crypto key verify {env.JWT_SHARED_KEY}
set auth url /auth
allow roles authp/admin authp/user
}
}
}
example.com {
route /auth* {
authenticate with myportal
}
route /app* {
authorize with app_policy
reverse_proxy 127.0.0.1:8080
}
}
Use the optional matcher forms only when needed:
authenticate /auth* with myportal
authorize /api/* with api_policy
Domain Map
- HTTP integrations:
configuration-http-integrations, parsed by
plugin_authn.go and plugin_authz.go.
- Authentication portals:
configuration-authentication, parsed by
caddyfile_authn.go and caddyfile_authn_*.go.
- Authorization policies:
configuration-authorization, parsed by
caddyfile_authz.go and caddyfile_authz_*.go.
- Crypto directives and token or System API keys:
configuration-crypto, parsed by caddyfile_authn_crypto.go and
caddyfile_authz_crypto.go, implemented by local
go-authcrunch/pkg/kms, and resolved by caddyfile_resolve.go.
- Reusable generic credentials:
configuration-credentials, parsed by
caddyfile_credentials.go.
- Local and LDAP stores:
configuration-identity-stores, parsed by
caddyfile_identity.go and caddyfile_identity_store.go.
- Messaging providers:
configuration-messaging, parsed by
caddyfile_messaging.go.
- OAuth/OIDC identity providers:
configuration-oauth-providers, parsed by
caddyfile_identity.go and caddyfile_identity_provider.go.
- SAML login identity providers:
configuration-saml-providers, parsed by
caddyfile_identity.go and caddyfile_identity_provider.go, implemented by
local go-authcrunch/pkg/idp/saml.
- User registrations:
configuration-registrations, parsed by
caddyfile_user.go and caddyfile_user_registration.go.
- Runtime placeholder and secret resolution:
configuration-runtime-resolution,
applied by caddyfile_resolve.go.
- Secrets managers and secret lookup syntax:
configuration-secrets, parsed by
caddyfile_secrets.go and resolved by caddyfile_resolve.go.
- SSO app providers:
configuration-sso-app, parsed by
caddyfile_sso_provider.go.
- Local user entries in identity stores:
configuration-users, parsed inside
caddyfile_identity_store.go.
- Portal JSON/admin APIs:
authentication-portal-api, implemented by local
go-authcrunch/pkg/authn/handle_* handlers and enabled in Caddyfile by
authentication portal options.
Keep this map synchronized with every directory matching
.codex/skills/configuration-*.
SAML identity-provider blocks are distinct from SSO app providers. Use
configuration-saml-providers for login through external SAML IdPs and
configuration-sso-app for portal-provided SAML SSO app endpoints.
Fixtures
Use these examples for orientation:
testdata/caddyfile_adapt/testcase_security_authentication_portal.Caddyfile
for local users, portal crypto, cookies, UI links, and transforms.
testdata/caddyfile_adapt/testcase_authenticate_with_oauth.Caddyfile for
OAuth plus authorization policy wiring.
testdata/caddyfile_adapt/testcase_authenticate_with_registration.Caddyfile
for registration, messaging, local users, and portal wiring.
testdata/caddyfile_adapt/testcase_security_with_secrets.Caddyfile for
secrets manager values consumed by users and crypto keys.
1---2name: configuration3description: caddy-security Caddyfile configuration generation for the security app and authenticate or authorize HTTP directives. Use when creating, reviewing, or modifying Caddyfile configs for authentication portals, authorization policies, identity stores, OAuth or SAML identity providers, SSO app providers, users, registration flows, messaging, credentials, secrets, or runtime replacement in this repository.4---56# Configuration78## Purpose910Use this skill as the entry point for generating caddy-security Caddyfile11configuration. Keep the parent skill as a router: load only the domain skills12needed for the requested configuration.1314The authoritative parser entry point is `caddyfile.go`. The global block is15`security { ... }`; route-level HTTP integrations reference configured objects16with `authenticate with <portal>` and `authorize with <policy>`.1718Do not generate global Caddy directive-order overrides for caddy-security by19default. `authenticate` and `authorize` register their own order in20`plugin_authn.go` and `plugin_authz.go`. Only add global `order` directives21when debugging a proven directive-order conflict with another third-party22plugin, and explain why.2324## Workflow25261. Identify the requested auth flow: local login, LDAP, OAuth/OIDC, SAML, API27 keys, basic auth, registration, SSO app, or policy-only authorization.282. Load only the relevant `configuration-*` domain skills from the Domain Map29 before drafting the Caddyfile.30 Load `configuration-http-integrations` whenever adding route-level31 `authenticate` or `authorize` handlers.32 Load `configuration-saml-providers` for `saml identity provider <name>`33 blocks; do not substitute the SSO app skill.34 Load `authentication-portal-api` when the request involves Portal API,35 JSON login, `/whoami`, `/beacon`, or admin/server API endpoints.363. Start from the smallest valid `security` app block, then add route handlers37 that reference the configured portal or policy by name.384. Prefer environment placeholders or secret lookups for passwords, API keys,39 client secrets, signing keys, and private material.405. Check generated syntax against the parser files and the fixtures under41 `testdata/caddyfile_adapt/`. Use the `testing-and-ci` skill if validation42 requires running tests or updating fixtures.4344## Common Shape4546```caddyfile47{48 security {49 local identity store localdb {50 realm local51 path assets/config/users.json52 }5354 authentication portal myportal {55 crypto key sign-verify {env.JWT_SHARED_KEY}56 enable identity store localdb57 }5859 authorization policy app_policy {60 crypto key verify {env.JWT_SHARED_KEY}61 set auth url /auth62 allow roles authp/admin authp/user63 }64 }65}6667example.com {68 route /auth* {69 authenticate with myportal70 }7172 route /app* {73 authorize with app_policy74 reverse_proxy 127.0.0.1:808075 }76}77```7879Use the optional matcher forms only when needed:8081```caddyfile82authenticate /auth* with myportal83authorize /api/* with api_policy84```8586## Domain Map8788- HTTP integrations: `configuration-http-integrations`, parsed by89 `plugin_authn.go` and `plugin_authz.go`.90- Authentication portals: `configuration-authentication`, parsed by91 `caddyfile_authn.go` and `caddyfile_authn_*.go`.92- Authorization policies: `configuration-authorization`, parsed by93 `caddyfile_authz.go` and `caddyfile_authz_*.go`.94- Crypto directives and token or System API keys:95 `configuration-crypto`, parsed by `caddyfile_authn_crypto.go` and96 `caddyfile_authz_crypto.go`, implemented by local97 `go-authcrunch/pkg/kms`, and resolved by `caddyfile_resolve.go`.98- Reusable generic credentials: `configuration-credentials`, parsed by99 `caddyfile_credentials.go`.100- Local and LDAP stores: `configuration-identity-stores`, parsed by101 `caddyfile_identity.go` and `caddyfile_identity_store.go`.102- Messaging providers: `configuration-messaging`, parsed by103 `caddyfile_messaging.go`.104- OAuth/OIDC identity providers: `configuration-oauth-providers`, parsed by105 `caddyfile_identity.go` and `caddyfile_identity_provider.go`.106- SAML login identity providers: `configuration-saml-providers`, parsed by107 `caddyfile_identity.go` and `caddyfile_identity_provider.go`, implemented by108 local `go-authcrunch/pkg/idp/saml`.109- User registrations: `configuration-registrations`, parsed by110 `caddyfile_user.go` and `caddyfile_user_registration.go`.111- Runtime placeholder and secret resolution: `configuration-runtime-resolution`,112 applied by `caddyfile_resolve.go`.113- Secrets managers and secret lookup syntax: `configuration-secrets`, parsed by114 `caddyfile_secrets.go` and resolved by `caddyfile_resolve.go`.115- SSO app providers: `configuration-sso-app`, parsed by116 `caddyfile_sso_provider.go`.117- Local user entries in identity stores: `configuration-users`, parsed inside118 `caddyfile_identity_store.go`.119- Portal JSON/admin APIs: `authentication-portal-api`, implemented by local120 `go-authcrunch/pkg/authn/handle_*` handlers and enabled in Caddyfile by121 authentication portal options.122123Keep this map synchronized with every directory matching124`.codex/skills/configuration-*`.125126SAML identity-provider blocks are distinct from SSO app providers. Use127`configuration-saml-providers` for login through external SAML IdPs and128`configuration-sso-app` for portal-provided SAML SSO app endpoints.129130## Fixtures131132Use these examples for orientation:133134- `testdata/caddyfile_adapt/testcase_security_authentication_portal.Caddyfile`135 for local users, portal crypto, cookies, UI links, and transforms.136- `testdata/caddyfile_adapt/testcase_authenticate_with_oauth.Caddyfile` for137 OAuth plus authorization policy wiring.138- `testdata/caddyfile_adapt/testcase_authenticate_with_registration.Caddyfile`139 for registration, messaging, local users, and portal wiring.140- `testdata/caddyfile_adapt/testcase_security_with_secrets.Caddyfile` for141 secrets manager values consumed by users and crypto keys.