You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/proposals/nap-waf.md
+15-52Lines changed: 15 additions & 52 deletions
Original file line number
Diff line number
Diff line change
@@ -61,9 +61,10 @@ A key design principle is seamless GitOps workflow support through automatic cha
61
61
62
62
The design uses **inherited policy attachment** following Gateway API best practices:
63
63
64
+
-**Single target per policy**: A WafPolicy targets a single resource (either a Gateway or a Route) following [gep-2649 guidelines](https://gateway-api.sigs.k8s.io/geps/gep-2649/#policy-targetref-api).
64
65
-**Gateway-level policies** provide default protection for all routes attached to the Gateway
65
66
-**Route-level policies** can override Gateway-level policies for specific routes requiring different protection
66
-
- NB: cannot _disable_WAF protection on a per route level, but the Routelevel WAFPolicy configuration will completely override the Gatewaylevel WAFPolicy configuration
67
+
- NB: Route-level WafPolicies always override Gateway-level WafPolicies for routes they explicitly target. However, it is not possible to completely disable WAF protection for a specific Route when a Gateway-level WafPolicy is active. Instead, the Route-level policy configuration entirely replaces the Gateway-level policy for that route.
67
68
-**Policy precedence**: More specific policies (Route-level) override less specific policies (Gateway-level)
68
69
-**Automatic inheritance**: New routes automatically receive Gateway-level protection without explicit configuration
69
70
@@ -207,7 +208,7 @@ This architecture demonstrates the hierarchical policy attachment system where G
207
208
208
209
**Application Namespace Resources:** All user-facing resources (Gateway, HTTPRoute, GRPCRoute, WafPolicy, NginxProxy, and optional authentication Secret) reside in application namespaces for proper isolation and RBAC management. The Secret is only required when using fallback authentication methods for accessing external policy storage - native cloud authentication (where available) uses annotations on the NGF service account in the nginx-gateway namespace.
209
210
210
-
**Policy Attachment Flow (Orange):** WafPolicy resources use targetRefs to attach to Gateways or Routes. Gateway-level policies provide inherited protection for all attached HTTPRoutes and GRPCRoutes. Route-level policies can override Gateway-level policies for specific routes requiring different protection levels.
211
+
**Policy Attachment Flow (Orange):** WafPolicy resources use targetRef to attach to Gateways or Routes. Only one resource can be targeted at a time. Gateway-level policies provide inherited protection for all attached HTTPRoutes and GRPCRoutes. Route-level policies can override Gateway-level policies for specific routes requiring different protection levels.
211
212
212
213
**Traffic Flow (Yellow/Gold):** Client traffic (HTTP, HTTPS, and gRPC) flows through the public load balancer endpoint to the WAF-protected NGINX container, where NAP v5 applies security policies before forwarding filtered traffic to backend applications.
213
214
@@ -258,7 +259,7 @@ spec:
258
259
2. **Log Profile Development**: Create custom logging profiles or use built-in profiles (log_all, log_blocked, etc.)
259
260
3. **Compilation**: Use NAP v5 compiler tools to create policy and logging profile bundles
260
261
4. **Distribution**: Publish compiled policies and log profiles to accessible storage (S3, HTTP)
261
-
5. **Configuration**: Create WafPolicy CR with targetRefs referencing Gateway or Routes and configuring security logging
262
+
5. **Configuration**: Create WafPolicy CR with targetRef referencing a Gateway or a Route and configuring security logging
262
263
6. **Automatic Application**: NGF fetches and applies policies when WafPolicy is created or updated, with automatic inheritance. Policies can also be updated by publishing new content to the same configured file path; when polling is enabled, NGF automatically detects and applies changes.
263
264
264
265
**Note**: Policy enforcement mode and behavior are defined within the compiled NAP policy itself. Security logging profiles can be either built-in names or custom compiled bundles.
@@ -434,8 +435,8 @@ metadata:
434
435
namespace: applications
435
436
spec:
436
437
# Policy attachment - targets Gateway for inherited protection
437
-
targetRefs:
438
-
-group: gateway.networking.k8s.io
438
+
targetRef:
439
+
group: gateway.networking.k8s.io
439
440
kind: Gateway
440
441
name: secure-gateway
441
442
namespace: applications
@@ -518,8 +519,8 @@ metadata:
518
519
namespace: applications
519
520
spec:
520
521
# Policy attachment - targets specific HTTPRoute to override Gateway policy
521
-
targetRefs:
522
-
-group: gateway.networking.k8s.io
522
+
targetRef:
523
+
group: gateway.networking.k8s.io
523
524
kind: HTTPRoute
524
525
name: admin-route
525
526
namespace: applications
@@ -603,7 +604,7 @@ spec:
603
604
backendRefs:
604
605
- name: admin-service
605
606
port: 8080
606
-
# Uses admin-strict-policy WafPolicy override via targetRefs
607
+
# Uses admin-strict-policy WafPolicy override via targetRef
607
608
```
608
609
609
610
#### GRPCRoute Integration
@@ -802,7 +803,7 @@ Some additional rules:
802
803
803
804
- **NginxProxy Extensions**: WAF enablement configuration parsing and validation
804
805
- **WafPolicy Controller**: CRUD operations, status management, and policy fetching logic
805
-
- **Policy Attachment Logic**: targetRefs validation and inheritance resolution
806
+
- **Policy Attachment Logic**: targetRef validation and inheritance resolution
806
807
- **Multi-container Orchestration**: Container startup sequences and ephemeral volume management
0 commit comments