Skip to content

Commit f2d0381

Browse files
committed
Switch to using regular expressions as per @simo5 review comments.
1 parent 1db3db0 commit f2d0381

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
@@ -242,16 +242,16 @@ frontend fe_sni
242242
{{- with (env "ROUTER_MUTUAL_TLS_AUTH_FILTER") }}
243243
# If a mutual TLS auth subject filter environment variable is set, we deny
244244
# requests if the DN field in the client certificate doesn't match that value.
245-
# Please note that this match is a subset (substring) match.
245+
# Please note that this match is a regular expression match.
246246
# Example: For DN set to: /CN=header.test/ST=CA/C=US/O=Security/OU=OpenShift3,
247247
# A. ROUTER_MUTUAL_TLS_AUTH_FILTER="header.test" OR
248248
# ROUTER_MUTUAL_TLS_AUTH_FILTER="head" OR
249-
# ROUTER_MUTUAL_TLS_AUTH_FILTER="/CN=header.test/ST=CA/C=US/O=Security/OU=OpenShift3" /* exact match example */
249+
# ROUTER_MUTUAL_TLS_AUTH_FILTER="^/CN=header.test/ST=CA/C=US/O=Security/OU=OpenShift3$" /* exact match example */
250250
# the filter would match the DN field (substring or exact match)
251251
# and the request will be passed on to the backend.
252252
# B. ROUTER_MUTUAL_TLS_AUTH_FILTER="legacy-web-client", the request
253253
# will be rejected.
254-
acl cert_cn_matches ssl_c_s_dn -m sub {{.}}
254+
acl cert_cn_matches ssl_c_s_dn -m reg {{.}}
255255
http-request deny unless cert_cn_matches
256256
{{- end }}
257257

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

pkg/oc/admin/router/router.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ func NewCmdRouter(f kcmdutil.Factory, parentName, name string, out, errout io.Wr
341341
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.")
342342
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.")
343343
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.")
344-
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.")
344+
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.")
345345

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

0 commit comments

Comments
 (0)