Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support forward client cert config XFCC header #3202

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
8b806a1
feat: support forward client cert config XFCC headers
zufardhiyaulhaq Apr 15, 2024
6d4824c
feat: add clientCertDetailsConfiguration to configure xfcc header
zufardhiyaulhaq Apr 16, 2024
6d14974
Merge branch 'main' into support-forward-client-details-XFCC
zufardhiyaulhaq Apr 20, 2024
819f9cf
feat: fix sites
zufardhiyaulhaq Apr 20, 2024
cc85e7b
feat: fix unit tests
zufardhiyaulhaq Apr 20, 2024
ca813a4
feat: move xfcc configuration to tls.clientvalidation & group into 1 …
zufardhiyaulhaq Apr 20, 2024
a380bc7
Merge branch 'envoyproxy:main' into support-forward-client-details-XFCC
zufardhiyaulhaq Apr 20, 2024
c19d46b
feat: fix gen-check
zufardhiyaulhaq Apr 20, 2024
dc63165
feat: fix API removing uniqueItems & trailing space on test data
zufardhiyaulhaq Apr 20, 2024
ecb05dd
Merge branch 'main' into support-forward-client-details-XFCC
zufardhiyaulhaq May 12, 2024
f73d19b
fix: API & implementation moving ForwardClientSet to Headers
zufardhiyaulhaq May 12, 2024
e32525b
Merge branch 'main' into support-forward-client-details-XFCC
zufardhiyaulhaq May 18, 2024
162c4a0
feat: move unit tests to headers & fix logic on headers
zufardhiyaulhaq May 18, 2024
0a20704
feat: fix logic on xds listener & unit tests
zufardhiyaulhaq May 18, 2024
c611348
feat: fix gen-check
zufardhiyaulhaq May 19, 2024
4bba6ca
feat: fix gen-check
zufardhiyaulhaq May 19, 2024
562a6b3
feat: fix lint
zufardhiyaulhaq May 19, 2024
a82c4a8
feat: change forwardClientCert to xForwardedClientCert
zufardhiyaulhaq May 20, 2024
de03f58
Merge branch 'main' into support-forward-client-details-XFCC
zufardhiyaulhaq May 20, 2024
812d2c8
fix gen-check job
zufardhiyaulhaq May 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions api/v1alpha1/clienttrafficpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ type HeaderSettings struct {
// is encountered. The default action is to reject the request.
// +optional
WithUnderscoresAction *WithUnderscoresAction `json:"withUnderscoresAction,omitempty"`

// configure Envoy proxy to forward x-forwarded-client-cert (XFCC) HTTP header
zufardhiyaulhaq marked this conversation as resolved.
Show resolved Hide resolved
ForwardClientCertDetails *ForwardClientCertDetails `json:"forwardClientCertDetails,omitempty"`
}

// WithUnderscoresAction configures the action to take when an HTTP header with underscores
Expand All @@ -123,6 +126,26 @@ const (
WithUnderscoresActionDropHeader WithUnderscoresAction = "DropHeader"
)

// +kubebuilder:validation:Enum=Sanitize;ForwardOnly;AppendForward;SanitizeSet;AlwaysForwardOnly
type ForwardClientCertDetails string

const (
// Do not send the XFCC header to the next hop. This is the default value.
ForwardClientCertDetailsSanitize ForwardClientCertDetails = "Sanitize"
// When the client connection is mTLS (Mutual TLS), forward the XFCC header
// in the request.
ForwardClientCertDetailsForwardOnly ForwardClientCertDetails = "ForwardOnly"
// When the client connection is mTLS, append the client certificate
// information to the request’s XFCC header and forward it.
ForwardClientCertDetailsAppendForward ForwardClientCertDetails = "AppendForward"
// When the client connection is mTLS, reset the XFCC header with the client
// certificate information and send it to the next hop.
ForwardClientCertDetailsSanitizeSet ForwardClientCertDetails = "SanitizeSet"
// Always forward the XFCC header in the request, regardless of whether the
// client connection is mTLS.
ForwardClientCertDetailsAlwaysForwardOnly ForwardClientCertDetails = "AlwaysForwardOnly"
)

// ClientIPDetectionSettings provides configuration for determining the original client IP address for requests.
//
// +kubebuilder:validation:XValidation:rule="!(has(self.xForwardedFor) && has(self.customHeader))",message="customHeader cannot be used in conjunction with xForwardedFor"
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ spec:
EnableEnvoyHeaders configures Envoy Proxy to add the "X-Envoy-" headers to requests
and responses.
type: boolean
forwardClientCertDetails:
description: configure Envoy proxy to forward x-forwarded-client-cert
(XFCC) HTTP header
enum:
- Sanitize
- ForwardOnly
- AppendForward
- SanitizeSet
- AlwaysForwardOnly
type: string
withUnderscoresAction:
description: |-
WithUnderscoresAction configures the action to take when an HTTP header with underscores
Expand Down
14 changes: 14 additions & 0 deletions internal/ir/xds.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,16 @@ const (
WithUnderscoresActionDropHeader = WithUnderscoresAction(egv1a1.WithUnderscoresActionDropHeader)
)

type ForwardClientCertDetails egv1a1.ForwardClientCertDetails

const (
ForwardClientCertDetailsSanitize = ForwardClientCertDetails(egv1a1.ForwardClientCertDetailsSanitize)
ForwardClientCertDetailsForwardOnly = ForwardClientCertDetails(egv1a1.ForwardClientCertDetailsForwardOnly)
ForwardClientCertDetailsAppendForward = ForwardClientCertDetails(egv1a1.ForwardClientCertDetailsAppendForward)
ForwardClientCertDetailsSanitizeSet = ForwardClientCertDetails(egv1a1.ForwardClientCertDetailsSanitizeSet)
ForwardClientCertDetailsAlwaysForwardOnly = ForwardClientCertDetails(egv1a1.ForwardClientCertDetailsAlwaysForwardOnly)
)

// ClientIPDetectionSettings provides configuration for determining the original client IP address for requests.
// +k8s:deepcopy-gen=true
type ClientIPDetectionSettings egv1a1.ClientIPDetectionSettings
Expand Down Expand Up @@ -400,6 +410,10 @@ type HeaderSettings struct {
// Refer to https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/http/router/v3/router.proto#extensions-filters-http-router-v3-router
EnableEnvoyHeaders bool `json:"enableEnvoyHeaders,omitempty" yaml:"enableEnvoyHeaders,omitempty"`

// configure Envoy proxy to forward x-forwarded-client-cert (XFCC) HTTP header
// refer to https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto#envoy-v3-api-enum-extensions-filters-network-http-connection-manager-v3-httpconnectionmanager-forwardclientcertdetails
ForwardClientCertDetails ForwardClientCertDetails `json:"forwardClientCertDetails,omitempty"`

// WithUnderscoresAction configures the action to take when an HTTP header with underscores
// is encountered. The default action is to reject the request.
// Refer to https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/core/v3/protocol.proto#envoy-v3-api-enum-config-core-v3-httpprotocoloptions-headerswithunderscoresaction
Expand Down
21 changes: 20 additions & 1 deletion internal/xds/translator/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ func (t *Translator) addHCMToXDSListener(xdsListener *listenerv3.Listener, irLis
CommonHttpProtocolOptions: &corev3.HttpProtocolOptions{
HeadersWithUnderscoresAction: buildHeadersWithUnderscoresAction(irListener.Headers),
},
Tracing: hcmTracing,
ForwardClientCertDetails: buildForwardClientCertDetailsAction(irListener.Headers),
Tracing: hcmTracing,
}

if irListener.Timeout != nil && irListener.Timeout.HTTP != nil {
Expand Down Expand Up @@ -775,3 +776,21 @@ func buildHeadersWithUnderscoresAction(in *ir.HeaderSettings) corev3.HttpProtoco
}
return corev3.HttpProtocolOptions_REJECT_REQUEST
}

func buildForwardClientCertDetailsAction(in *ir.HeaderSettings) hcmv3.HttpConnectionManager_ForwardClientCertDetails {
if in != nil {
switch in.ForwardClientCertDetails {
case ir.ForwardClientCertDetailsSanitize:
return hcmv3.HttpConnectionManager_SANITIZE
case ir.ForwardClientCertDetailsForwardOnly:
return hcmv3.HttpConnectionManager_FORWARD_ONLY
case ir.ForwardClientCertDetailsAppendForward:
return hcmv3.HttpConnectionManager_APPEND_FORWARD
case ir.ForwardClientCertDetailsSanitizeSet:
return hcmv3.HttpConnectionManager_SANITIZE_SET
case ir.ForwardClientCertDetailsAlwaysForwardOnly:
return hcmv3.HttpConnectionManager_ALWAYS_FORWARD_ONLY
}
}
return hcmv3.HttpConnectionManager_SANITIZE
zufardhiyaulhaq marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
http:
- name: "first-listener"
address: "0.0.0.0"
port: 8081
hostnames:
- "*"
routes:
- name: "first-route"
hostname: "*"
destination:
name: "first-route-dest"
settings:
- endpoints:
- host: "1.1.1.1"
port: 8081
- name: "second-listener"
address: "0.0.0.0"
port: 8082
hostnames:
- "*"
routes:
- name: "second-route"
hostname: "*"
destination:
name: "second-route-dest"
settings:
- endpoints:
- host: "2.2.2.2"
port: 8082
headers:
forwardClientCertDetails: Sanitize
- name: "third-listener"
address: "0.0.0.0"
port: 8083
hostnames:
- "*"
routes:
- name: "third-route"
hostname: "*"
destination:
name: "third-route-dest"
settings:
- endpoints:
- host: "3.3.3.3"
port: 8083
headers:
forwardClientCertDetails: ForwardOnly
- name: "fourth-listener"
address: "0.0.0.0"
port: 8084
hostnames:
- "*"
routes:
- name: "fourth-route"
hostname: "*"
destination:
name: "fourth-route-dest"
settings:
- endpoints:
- host: "4.4.4.4"
port: 8084
headers:
forwardClientCertDetails: AppendForward
- name: "fifth-listener"
address: "0.0.0.0"
port: 8085
hostnames:
- "*"
routes:
- name: "fifth-route"
hostname: "*"
destination:
name: "fifth-route-dest"
settings:
- endpoints:
- host: "5.5.5.5"
port: 8085
headers:
forwardClientCertDetails: SanitizeSet
- name: "sixth-listener"
address: "0.0.0.0"
port: 8086
hostnames:
- "*"
routes:
- name: "sixth-route"
hostname: "*"
destination:
name: "sixth-route-dest"
settings:
- endpoints:
- host: "6.6.6.6"
port: 8086
headers:
forwardClientCertDetails: AlwaysForwardOnly
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
- circuitBreakers:
thresholds:
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
dnsLookupFamily: V4_ONLY
edsClusterConfig:
edsConfig:
ads: {}
resourceApiVersion: V3
serviceName: first-route-dest
lbPolicy: LEAST_REQUEST
name: first-route-dest
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- circuitBreakers:
thresholds:
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
dnsLookupFamily: V4_ONLY
edsClusterConfig:
edsConfig:
ads: {}
resourceApiVersion: V3
serviceName: second-route-dest
lbPolicy: LEAST_REQUEST
name: second-route-dest
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- circuitBreakers:
thresholds:
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
dnsLookupFamily: V4_ONLY
edsClusterConfig:
edsConfig:
ads: {}
resourceApiVersion: V3
serviceName: third-route-dest
lbPolicy: LEAST_REQUEST
name: third-route-dest
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- circuitBreakers:
thresholds:
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
dnsLookupFamily: V4_ONLY
edsClusterConfig:
edsConfig:
ads: {}
resourceApiVersion: V3
serviceName: fourth-route-dest
lbPolicy: LEAST_REQUEST
name: fourth-route-dest
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- circuitBreakers:
thresholds:
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
dnsLookupFamily: V4_ONLY
edsClusterConfig:
edsConfig:
ads: {}
resourceApiVersion: V3
serviceName: fifth-route-dest
lbPolicy: LEAST_REQUEST
name: fifth-route-dest
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- circuitBreakers:
thresholds:
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
dnsLookupFamily: V4_ONLY
edsClusterConfig:
edsConfig:
ads: {}
resourceApiVersion: V3
serviceName: sixth-route-dest
lbPolicy: LEAST_REQUEST
name: sixth-route-dest
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
- clusterName: first-route-dest
endpoints:
- lbEndpoints:
- endpoint:
address:
socketAddress:
address: 1.1.1.1
portValue: 8081
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: first-route-dest/backend/0
- clusterName: second-route-dest
endpoints:
- lbEndpoints:
- endpoint:
address:
socketAddress:
address: 2.2.2.2
portValue: 8082
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: second-route-dest/backend/0
- clusterName: third-route-dest
endpoints:
- lbEndpoints:
- endpoint:
address:
socketAddress:
address: 3.3.3.3
portValue: 8083
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: third-route-dest/backend/0
- clusterName: fourth-route-dest
endpoints:
- lbEndpoints:
- endpoint:
address:
socketAddress:
address: 4.4.4.4
portValue: 8084
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: fourth-route-dest/backend/0
- clusterName: fifth-route-dest
endpoints:
- lbEndpoints:
- endpoint:
address:
socketAddress:
address: 5.5.5.5
portValue: 8085
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: fifth-route-dest/backend/0
- clusterName: sixth-route-dest
endpoints:
- lbEndpoints:
- endpoint:
address:
socketAddress:
address: 6.6.6.6
portValue: 8086
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: sixth-route-dest/backend/0
Loading
Loading