# One file per application namespace: refuse everything, then allow each call # by the caller's service account. Copy it for each namespace you onboard, # once its sidecars are injected. --- # Refuses any request with no mesh identity. A DENY wins over every ALLOW, so # if someone later loosens mutual TLS for this namespace, anonymous callers # are still refused. apiVersion: security.istio.io/v1 kind: AuthorizationPolicy metadata: name: deny-anonymous namespace: shop spec: action: DENY rules: - from: - source: notPrincipals: ["*"] --- apiVersion: security.istio.io/v1 kind: AuthorizationPolicy metadata: name: allow-nothing namespace: shop spec: {} --- apiVersion: security.istio.io/v1 kind: AuthorizationPolicy metadata: name: frontend-calls-backend namespace: shop spec: selector: matchLabels: app: backend action: ALLOW rules: - from: - source: principals: ["cluster.local/ns/shop/sa/frontend"] to: - operation: methods: ["GET", "POST"] paths: ["/api/*"] --- # The ingress gateway is a caller too, and needs its own allow. apiVersion: security.istio.io/v1 kind: AuthorizationPolicy metadata: name: gateway-calls-frontend namespace: shop spec: selector: matchLabels: app: frontend action: ALLOW rules: - from: - source: principals: ["cluster.local/ns/istio-ingress/sa/istio-ingressgateway"]