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
@@ -308,7 +308,7 @@ However, targeting a `Service` introduces several challenges;
308
308
309
309
##### Loss Of Service Context
310
310
311
-
I we go with option 1, apply authorization policy to all traffic addressed to a service;
311
+
If we go with option 1, apply authorization policy to all traffic addressed to a service;
312
312
This option is very tricky to implement for sidecar-based meshes where the destination sidecar has no knowledge of which Service the request came through.
313
313
Here is the very high-level tarffic flow for sidecar-based meshes:
314
314
@@ -350,8 +350,7 @@ The UX becomes very confusing. Are we going to enforce only if the traffic arriv
350
350
351
351
The UX gets weird becuase even though you target a service, you essentially get a **workload** policy, thats enforced regardless.
352
352
353
-
354
-
> Note: with Service as a targetRef, of course we are going to need a Service in order to enforce Authorization -- meaning pods/jobs without a serivce are completely out of scope.
353
+
> Note: with Service as a targetRef, of course we are going to need a Service in order to enforce Authorization -- meaning pods/jobs without a Serivce are completely out of scope.
Without dedicated tooling, the `LabelSelector` approach could significantly degrade the user experience and observability.
477
476
477
+
#### Recommended Option - Hybrid TargetRef and VAP
478
+
479
+
Adding only the recommendation below, please see [https://docs.google.com/document/d/1CeagBnHDPbzpYAxBmtJqTshxAW8l-aRPwvwgAGbnv2I/edit?tab=t.0](https://docs.google.com/document/d/1CeagBnHDPbzpYAxBmtJqTshxAW8l-aRPwvwgAGbnv2I/edit?tab=t.0) for a comprehensive comparison for design options for TargetRef.
480
+
481
+
Create one unified authorization policy API with implementation-specific validation using Validating Admission Policies (VAP). Additionally introducing a new `enforcementLevel` enum to simplify validation and enable the user to clarify intent
482
+
483
+
```
484
+
# Network-scoped policy (L4 enforcement points)
485
+
kind: AuthorizationPolicy
486
+
metadata:
487
+
name: network-authz
488
+
spec:
489
+
enforcementLevel: "network"# Enforced at L4 proxies
490
+
targetRef:
491
+
kind: Pod
492
+
selector: {}
493
+
rules:
494
+
- authorizationSource:
495
+
serviceAccount: ["default/productpage"]
496
+
tcpAttributes:
497
+
ports: [9080]
498
+
499
+
# Application-scoped policy (L7-only enforcement points and sidecars)
500
+
kind: AuthorizationPolicy
501
+
metadata:
502
+
name: app-authz
503
+
spec:
504
+
enforcementLevel: "application"# Enforced at L7 proxies
505
+
targetRef: # Service for Ambient implementations, label-selector for sidecar implementations.
506
+
rules:
507
+
- authorizationSource:
508
+
serviceAccount: ["default/productpage"]
509
+
tcpAttributes:
510
+
ports: [9080]
511
+
httpAttributes:
512
+
paths: ["/api/*"]
513
+
methods: ["GET", "POST"]
514
+
515
+
516
+
```
517
+
518
+
### Mesh Implementation Behavior
519
+
520
+
Sidecar Meshes
521
+
522
+
***Network Level**: Sidecar enforces policy but only uses L4 attributes
523
+
***Application Level**: Sidecar enforces policy with full L4+L7 capabilities
524
+
525
+
Ambient Meshes
526
+
527
+
***Network Level**: Node-L4-proxy enforces policy using labelSelector targeting
528
+
***Application Level**: Waypoint proxy enforces policy using service targetRef targeting
529
+
530
+
**VAP Validation**:
531
+
532
+
***Sidecar mesh**: Ensures application-level policies don't use targetRef: Service (since sidecars use labelSelector)
533
+
* **Ambient**: Ensures application-level policies don't use label-selectors.
534
+
***Both sidecar and ambient:** ensures network level policies **do** use label selectors
535
+
536
+
Advantages
537
+
538
+
***Clear Intent**: Users explicitly state where they want enforcement
539
+
***Flexible Targeting**: Different targetRef types for different enforcement points
540
+
***Migration Path**: Users can start with network-level and upgrade to application-level easily
541
+
***Implementation Alignment**: supporting different meshes architectures
542
+
***Single API**: No duplication of schemas or concepts
543
+
***Validation Clarity**: Clear rules about what's allowed at each level
544
+
545
+
Disadvantages
546
+
547
+
* **Complexity**: Users must understand enforcement levels
548
+
* **VAP Dependency**: Requires validation rules
549
+
478
550
### API Design
479
551
480
552
```go
@@ -511,33 +583,55 @@ type AuthorizationPolicySpec struct {
511
583
// +kubebuilder:validation:Required
512
584
Action AuthorizationPolicyAction `json:"action"`
513
585
514
-
// TCPRules defines the list of matching criteria. A request is considered to
515
-
// match the policy if it matches any of the rules.
586
+
// Rules defines the list of authorization rules.
587
+
// A request matches the policy if it matches any of these rules.
0 commit comments