Skip to content

Commit

Permalink
Fixes as per @simo5 review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
ramr committed May 31, 2018
1 parent d3894ad commit 567e915
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions images/router/haproxy/conf/haproxy-config.template
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,11 @@ frontend fe_sni

{{- if ne (env "ROUTER_MUTUAL_TLS_AUTH" "none") "none" }}
{{- with (env "ROUTER_MUTUAL_TLS_AUTH_CN") }}
# If a mutual TLS auth CN is set, we deny requests if the common name doesn't
# match. A custom template can change this behavior (e.g. set custom headers).
# If a mutual TLS auth CN environment variable is set, we deny requests if the
# common name field in the client certificate doesn't match that environment
# variable value. Please note this match is a subset (substring) match.
# A custom template can customize this behavior as desired - as an example,
# it may want to set custom headers rather than deny requests.
acl cert_cn_matches ssl_c_s_dn(CN) -m sub {{.}}
http-request deny unless cert_cn_matches
{{- end }}
Expand All @@ -250,6 +253,7 @@ frontend fe_sni
http-request set-header X-SSL-Issuer %{+Q}[ssl_c_i_dn]
http-request set-header X-SSL-Client-NotBefore %{+Q}[ssl_c_notbefore]
http-request set-header X-SSL-Client-NotAfter %{+Q}[ssl_c_notafter]
http-request set-header X-SSL-Client-DER %{+Q}[ssl_c_der,base64]
{{- end }}

# map to backend
Expand Down Expand Up @@ -292,8 +296,11 @@ frontend fe_no_sni

{{- if ne (env "ROUTER_MUTUAL_TLS_AUTH" "none") "none" }}
{{- with (env "ROUTER_MUTUAL_TLS_AUTH_CN") }}
# If a mutual TLS auth CN is set, we deny requests if the common name doesn't
# match. A custom template can change this behavior (e.g. set custom headers).
# If a mutual TLS auth CN environment variable is set, we deny requests if the
# common name field in the client certificate doesn't match that environment
# variable value. Please note this match is a subset (substring) match.
# A custom template can customize this behavior as desired - as an example,
# it may want to set custom headers rather than deny requests.
acl cert_cn_matches ssl_c_s_dn(CN) -m sub {{.}}
http-request deny unless cert_cn_matches
{{- end }}
Expand All @@ -309,6 +316,7 @@ frontend fe_no_sni
http-request set-header X-SSL-Issuer %{+Q}[ssl_c_i_dn]
http-request set-header X-SSL-Client-NotBefore %{+Q}[ssl_c_notbefore]
http-request set-header X-SSL-Client-NotAfter %{+Q}[ssl_c_notafter]
http-request set-header X-SSL-Client-DER %{+Q}[ssl_c_der,base64]
{{- end }}

# map to backend
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/admin/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func generateMutualTLSSecretName(prefix string) string {

// generateSecretsConfig generates any Secret and Volume objects, such
// as SSH private keys, that are necessary for the router container.
func generateSecretsConfig(cfg *RouterConfig, namespace string, certName string, defaultCert, mtlsAuthCA, mtlsAuthCRL []byte) ([]*kapi.Secret, []kapi.Volume, []kapi.VolumeMount, error) {
func generateSecretsConfig(cfg *RouterConfig, namespace, certName string, defaultCert, mtlsAuthCA, mtlsAuthCRL []byte) ([]*kapi.Secret, []kapi.Volume, []kapi.VolumeMount, error) {
var secrets []*kapi.Secret
var volumes []kapi.Volume
var mounts []kapi.VolumeMount
Expand Down

0 comments on commit 567e915

Please sign in to comment.