Open
Description
The Gateway API currently lacks a standardized authorization policy, a critical requirement for production deployments, particularly as cloud infrastructure increasingly adopts zero-trust security models where granular access control is essential.
This proposal outlines an L7 Authorization Policy specifically designed for L7 Gateways and L7 workloads within a service mesh, explicitly excluding applicability to L4 Gateways or raw TCP-based workloads such as databases like MongoDB and Redis.
Here is the proposed CRD
const (
// AllGatewaysinNS applies the policy to all gateways in the same namespace.
AllGatewaysinNS GatewayApplyTo = "SameNamespace"
// TargetRefs applies the policy to the specified gateways in the targetRefs.
TargetRefs GatewayApplyTo = "TargetRefs"
)
const (
// Allow a request only if it matches the rules. This is the default type.
Allow AuthzPolicyAction = "ALLOW"
// Deny a request if it matches any of the rules.
Deny AuthzPolicyAction = "DENY"
// Custom action allows an extension to handle the user request if
// the matching rules evaluate to true.
Custom AuthzPolicyAction = "CUSTOM"
)
type AuthzPolicySpec struct {
HTTPRules []AuthPolicyHTTPRule `json:"httpRules,omitempty"`
Action *AuthzPolicyAction `json:"action,omitempty"`
// CustomProviders defines the extension providers for authorization policy.
CustomProviders *AuthzPolicyCustomProviders `json:"customProviders,omitempty"`
TargetRefs []v1.LocalObjectReference `json:"-"`
// Mesh identifies the mesh workloads to which the policy is applied.
Mesh *Mesh `json:"mesh,omitempty"`
// Gateway identifies the gateways to which the policy is applied.
Gateway *Gateway `json:"gateway,omitempty"`
}
type AuthPolicyHTTPRule struct {
// From will have client identities
From *AuthzPolicyFrom `json:"from,omitempty"`
// To will have path, host, port, headers, method
To *AuthzPolicyTo `json:"to,omitempty"`
// any valid conditional CEL expression
When *string `json:"when,omitempty"`
}
// WorkloadSelector defines the selector for the workloads to which the policy is applied.
type WorkloadSelector struct {
MatchLabels map[string]string `json:"matchLabels,omitempty"`
}
// Mesh defines the mesh workloads to which the policy is applied.
type Mesh struct {
ApplyTo *MeshApplyTo `json:"applyTo,omitempty"`
Selector *WorkloadSelector `json:"selector,omitempty"`
}
// Gateway defines the gateway workloads to which the policy is applied.
type Gateway struct {
ApplyTo *GatewayApplyTo `json:"applyTo,omitempty"`
TargetRefs []v1alpha2.LocalPolicyTargetReferenceWithSectionName `json:"targetRefs,omitempty"`
}