Phase 3+4 of default-deny ingress plan. Replaces the `protected = bool` (default
false → unprotected) variable in `modules/kubernetes/ingress_factory` with
`auth = string` enum (default "required" → fail-closed). Touches every
ingress_factory caller so the audit decision is recorded explicitly in code.
ingress_factory (Phase 3):
- `auth = "required"`: standard Authentik forward-auth (the legacy
`protected = true` semantic).
- `auth = "public"`: forward-auth via the new `authentik-forward-auth-public`
middleware → dedicated public outpost → guest auto-bind. Logged-in users
keep their real identity.
- `auth = "none"`: no Authentik middleware. For Anubis-fronted content, native
client APIs (Git, /v2/, WebDAV), webhook receivers, the Authentik outpost
itself.
- `effective_anti_ai` default flips ON only when `auth = "none"` (auth-gated
ingresses don't need anti-AI noise; the auth flow already discourages bots).
Audit pass (Phase 4) across 96 ingress_factory call sites:
- 49 explicit `protected = true` → `auth = "required"`
- 8 explicit `protected = false` → `auth = "none"` (5) or `auth = "public"` (3)
- 64 previously-default (no protected line) → `auth = "required"` ADDED, then
reviewed individually:
* 9 Anubis-fronted (blog, www, kms, travel, f1, cyberchef, jsoncrack,
homepage, wrongmove UI, privatebin) → `auth = "none"`
* 22 native-client / programmatic surfaces (Forgejo Git+/v2/, webhook
handler, claude-memory MCP, Nextcloud WebDAV, Matrix, Vault CLI/OIDC,
xray VPN, ntfy, woodpecker webhooks, n8n triggers, ntfy push, dawarich
location ingestion, immich frame kiosk, headscale CP, send anonymous
drops, rybbit beacon, vaultwarden API, Authentik UI itself + outposts) →
`auth = "none"`
* Remaining ~33 → `auth = "required"` confirmed (admin tools, internal
UIs, services without app-level auth)
- Smoke-test promotions to `auth = "public"`: fire-planner public UI,
k8s-portal API, insta2spotify callback.
Three call sites in wrapper modules (`stacks/freedify/factory/`,
`stacks/reverse-proxy/modules/reverse_proxy/`) keep their internal `protected`
bool — they translate to `auth` internally, out of scope for this rename.
Behavior change: previously-default ingresses now fail closed (require
Authentik login) unless explicitly flipped to `auth = "none"` or
`auth = "public"`. This is the audit goal — no more accidentally-unprotected
surfaces. Sites that were intentionally public (Anubis content, native APIs,
webhooks) are now explicitly recorded as `auth = "none"`.
Drive-by: `modules/create-vm/main.tf` picked up cosmetic alignment via
`terraform fmt -recursive` during the audit. Behavior-neutral.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
91 lines
2.8 KiB
Text
91 lines
2.8 KiB
Text
# =============================================================================
|
|
# Stack Template — Copy this directory to stacks/<your-app>/ and customize.
|
|
# Then submit a PR to the infra repo.
|
|
# =============================================================================
|
|
#
|
|
# Prerequisites:
|
|
# 1. You are a namespace-owner in k8s_users (Vault KV secret/platform)
|
|
# 2. Your namespace already exists (created by vault stack)
|
|
# 3. You have Vault CLI access: vault login -method=oidc
|
|
#
|
|
# Steps:
|
|
# 1. cp -r stacks/_template stacks/myapp
|
|
# 2. mv stacks/myapp/main.tf.example stacks/myapp/main.tf
|
|
# 3. Search-replace <placeholders> below
|
|
# 4. Store secrets: vault kv put secret/<your-username>/myapp KEY=value
|
|
# 5. git checkout -b feat/myapp && git push
|
|
# 6. Open PR, get reviewed, merge
|
|
# 7. Admin runs: cd stacks/myapp && terragrunt apply
|
|
# =============================================================================
|
|
|
|
variable "tls_secret_name" {
|
|
type = string
|
|
sensitive = true
|
|
}
|
|
|
|
# NOTE: Your namespace is auto-created by the vault stack from k8s_users.
|
|
# Only add a kubernetes_namespace resource if you need a SEPARATE namespace
|
|
# for this specific app (not your user namespace).
|
|
|
|
module "tls_secret" {
|
|
source = "../../modules/kubernetes/setup_tls_secret"
|
|
namespace = "<your-namespace>" # e.g., "anca"
|
|
tls_secret_name = var.tls_secret_name
|
|
}
|
|
|
|
resource "kubernetes_deployment" "app" {
|
|
metadata {
|
|
name = "<app-name>"
|
|
namespace = "<your-namespace>"
|
|
}
|
|
spec {
|
|
replicas = 1
|
|
selector {
|
|
match_labels = { app = "<app-name>" }
|
|
}
|
|
template {
|
|
metadata {
|
|
labels = { app = "<app-name>" }
|
|
}
|
|
spec {
|
|
container {
|
|
name = "<app-name>"
|
|
image = "<dockerhub-user>/<app-name>:<tag>"
|
|
port {
|
|
container_port = 8080 # Change to your app's port
|
|
}
|
|
resources {
|
|
requests = { cpu = "10m", memory = "256Mi" }
|
|
limits = { memory = "256Mi" }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
lifecycle {
|
|
ignore_changes = [spec[0].template[0].spec[0].dns_config] # KYVERNO_LIFECYCLE_V1
|
|
}
|
|
}
|
|
|
|
resource "kubernetes_service" "app" {
|
|
metadata {
|
|
name = "<app-name>"
|
|
namespace = "<your-namespace>"
|
|
}
|
|
spec {
|
|
selector = { app = "<app-name>" }
|
|
port {
|
|
port = 80
|
|
target_port = 8080 # Match container_port above
|
|
}
|
|
}
|
|
}
|
|
|
|
module "ingress" {
|
|
source = "../../modules/kubernetes/ingress_factory"
|
|
namespace = "<your-namespace>"
|
|
name = "<app-name>"
|
|
tls_secret_name = var.tls_secret_name
|
|
dns_type = "proxied" # "proxied" (Cloudflare CDN), "non-proxied" (direct A/AAAA), or "none"
|
|
auth = "required" # "required" (Authentik login), "public" (anonymous bound to guest), or "none" (no auth)
|
|
}
|