Skip to content

Commit 06615ab

Browse files
committed
Switch to using regular expressions as per @simo5 review comments.
1 parent 982aed8 commit 06615ab

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

images/router/haproxy/conf/haproxy-config.template

+5-5
Original file line numberDiff line numberDiff line change
@@ -235,16 +235,16 @@ frontend fe_sni
235235
{{- with (env "ROUTER_MUTUAL_TLS_AUTH_FILTER") }}
236236
# If a mutual TLS auth subject filter environment variable is set, we deny
237237
# requests if the DN field in the client certificate doesn't match that value.
238-
# Please note that this match is a subset (substring) match.
238+
# Please note that this match is a regular expression match.
239239
# Example: For DN set to: /CN=header.test/ST=CA/C=US/O=Security/OU=OpenShift3,
240240
# A. ROUTER_MUTUAL_TLS_AUTH_FILTER="header.test" OR
241241
# ROUTER_MUTUAL_TLS_AUTH_FILTER="head" OR
242-
# ROUTER_MUTUAL_TLS_AUTH_FILTER="/CN=header.test/ST=CA/C=US/O=Security/OU=OpenShift3" /* exact match example */
242+
# ROUTER_MUTUAL_TLS_AUTH_FILTER="^/CN=header.test/ST=CA/C=US/O=Security/OU=OpenShift3$" /* exact match example */
243243
# the filter would match the DN field (substring or exact match)
244244
# and the request will be passed on to the backend.
245245
# B. ROUTER_MUTUAL_TLS_AUTH_FILTER="legacy-web-client", the request
246246
# will be rejected.
247-
acl cert_cn_matches ssl_c_s_dn -m sub {{.}}
247+
acl cert_cn_matches ssl_c_s_dn -m reg {{.}}
248248
http-request deny unless cert_cn_matches
249249
{{- end }}
250250

@@ -304,9 +304,9 @@ frontend fe_no_sni
304304
{{- with (env "ROUTER_MUTUAL_TLS_AUTH_FILTER") }}
305305
# If a mutual TLS auth subject filter environment variable is set, we deny
306306
# requests if the DN field in the client certificate doesn't match that value.
307-
# Please note that this match is a subset (substring) match.
307+
# Please note that this match is a regular expression match.
308308
# See the config section 'frontend fe_sni' for examples.
309-
acl cert_cn_matches ssl_c_s_dn -m sub {{.}}
309+
acl cert_cn_matches ssl_c_s_dn -m reg {{.}}
310310
http-request deny unless cert_cn_matches
311311
{{- end }}
312312

pkg/oc/admin/router/router.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ func NewCmdRouter(f kcmdutil.Factory, parentName, name string, out, errout io.Wr
337337
cmd.Flags().StringVar(&cfg.MutualTLSAuth, "mutual-tls-auth", cfg.MutualTLSAuth, "Controls access to the router using mutually agreed upon TLS configuration (example client certificates). You can choose one of 'required', 'optional', or 'none'. The default is none.")
338338
cmd.Flags().StringVar(&cfg.MutualTLSAuthCA, "mutual-tls-auth-ca", cfg.MutualTLSAuthCA, "Optional path to a file containing one or more CA certificates used for mutual TLS authentication. The CA certificate[s] are used by the router to verify a client's certificate.")
339339
cmd.Flags().StringVar(&cfg.MutualTLSAuthCRL, "mutual-tls-auth-crl", cfg.MutualTLSAuthCRL, "Optional path to a file containing the certificate revocation list used for mutual TLS authentication. The certificate revocation list is used by the router to verify a client's certificate.")
340-
cmd.Flags().StringVar(&cfg.MutualTLSAuthFilter, "mutual-tls-auth-filter", cfg.MutualTLSAuthFilter, "Optional value to filter the client certificates. If the client certificate subject field does _not_ contain (substring match) this value, requests will be rejected by the router.")
340+
cmd.Flags().StringVar(&cfg.MutualTLSAuthFilter, "mutual-tls-auth-filter", cfg.MutualTLSAuthFilter, "Optional regular expression to filter the client certificates. If the client certificate subject field does _not_ match this regular expression, requests will be rejected by the router.")
341341

342342
cfg.Action.BindForOutput(cmd.Flags())
343343
cmd.Flags().String("output-version", "", "The preferred API versions of the output objects")

0 commit comments

Comments
 (0)