Skip to content

Commit b2508ea

Browse files
author
OpenShift Bot
authored
Merge pull request #12441 from ramr/disable-ns-checks
Merged by openshift-bot
2 parents 00ee096 + b97a0d2 commit b2508ea

21 files changed

+276
-38
lines changed

contrib/completions/bash/oadm

+2
Original file line numberDiff line numberDiff line change
@@ -4424,6 +4424,8 @@ _oadm_router()
44244424
local_nonpersistent_flags+=("--create")
44254425
flags+=("--default-cert=")
44264426
local_nonpersistent_flags+=("--default-cert=")
4427+
flags+=("--disable-namespace-ownership-check")
4428+
local_nonpersistent_flags+=("--disable-namespace-ownership-check")
44274429
flags+=("--dry-run")
44284430
local_nonpersistent_flags+=("--dry-run")
44294431
flags+=("--expose-metrics")

contrib/completions/bash/oc

+2
Original file line numberDiff line numberDiff line change
@@ -4398,6 +4398,8 @@ _oc_adm_router()
43984398
local_nonpersistent_flags+=("--create")
43994399
flags+=("--default-cert=")
44004400
local_nonpersistent_flags+=("--default-cert=")
4401+
flags+=("--disable-namespace-ownership-check")
4402+
local_nonpersistent_flags+=("--disable-namespace-ownership-check")
44014403
flags+=("--dry-run")
44024404
local_nonpersistent_flags+=("--dry-run")
44034405
flags+=("--expose-metrics")

contrib/completions/bash/openshift

+8
Original file line numberDiff line numberDiff line change
@@ -4424,6 +4424,8 @@ _openshift_admin_router()
44244424
local_nonpersistent_flags+=("--create")
44254425
flags+=("--default-cert=")
44264426
local_nonpersistent_flags+=("--default-cert=")
4427+
flags+=("--disable-namespace-ownership-check")
4428+
local_nonpersistent_flags+=("--disable-namespace-ownership-check")
44274429
flags+=("--dry-run")
44284430
local_nonpersistent_flags+=("--dry-run")
44294431
flags+=("--expose-metrics")
@@ -9164,6 +9166,8 @@ _openshift_cli_adm_router()
91649166
local_nonpersistent_flags+=("--create")
91659167
flags+=("--default-cert=")
91669168
local_nonpersistent_flags+=("--default-cert=")
9169+
flags+=("--disable-namespace-ownership-check")
9170+
local_nonpersistent_flags+=("--disable-namespace-ownership-check")
91679171
flags+=("--dry-run")
91689172
local_nonpersistent_flags+=("--dry-run")
91699173
flags+=("--expose-metrics")
@@ -20805,6 +20809,8 @@ _openshift_infra_f5-router()
2080520809
local_nonpersistent_flags+=("--context=")
2080620810
flags+=("--denied-domains=")
2080720811
local_nonpersistent_flags+=("--denied-domains=")
20812+
flags+=("--disable-namespace-ownership-check")
20813+
local_nonpersistent_flags+=("--disable-namespace-ownership-check")
2080820814
flags+=("--f5-host=")
2080920815
local_nonpersistent_flags+=("--f5-host=")
2081020816
flags+=("--f5-http-vserver=")
@@ -20988,6 +20994,8 @@ _openshift_infra_router()
2098820994
local_nonpersistent_flags+=("--default-certificate-path=")
2098920995
flags+=("--denied-domains=")
2099020996
local_nonpersistent_flags+=("--denied-domains=")
20997+
flags+=("--disable-namespace-ownership-check")
20998+
local_nonpersistent_flags+=("--disable-namespace-ownership-check")
2099120999
flags+=("--extended-validation")
2099221000
local_nonpersistent_flags+=("--extended-validation")
2099321001
flags+=("--fields=")

contrib/completions/zsh/oadm

+2
Original file line numberDiff line numberDiff line change
@@ -4572,6 +4572,8 @@ _oadm_router()
45724572
local_nonpersistent_flags+=("--create")
45734573
flags+=("--default-cert=")
45744574
local_nonpersistent_flags+=("--default-cert=")
4575+
flags+=("--disable-namespace-ownership-check")
4576+
local_nonpersistent_flags+=("--disable-namespace-ownership-check")
45754577
flags+=("--dry-run")
45764578
local_nonpersistent_flags+=("--dry-run")
45774579
flags+=("--expose-metrics")

contrib/completions/zsh/oc

+2
Original file line numberDiff line numberDiff line change
@@ -4546,6 +4546,8 @@ _oc_adm_router()
45464546
local_nonpersistent_flags+=("--create")
45474547
flags+=("--default-cert=")
45484548
local_nonpersistent_flags+=("--default-cert=")
4549+
flags+=("--disable-namespace-ownership-check")
4550+
local_nonpersistent_flags+=("--disable-namespace-ownership-check")
45494551
flags+=("--dry-run")
45504552
local_nonpersistent_flags+=("--dry-run")
45514553
flags+=("--expose-metrics")

contrib/completions/zsh/openshift

+8
Original file line numberDiff line numberDiff line change
@@ -4572,6 +4572,8 @@ _openshift_admin_router()
45724572
local_nonpersistent_flags+=("--create")
45734573
flags+=("--default-cert=")
45744574
local_nonpersistent_flags+=("--default-cert=")
4575+
flags+=("--disable-namespace-ownership-check")
4576+
local_nonpersistent_flags+=("--disable-namespace-ownership-check")
45754577
flags+=("--dry-run")
45764578
local_nonpersistent_flags+=("--dry-run")
45774579
flags+=("--expose-metrics")
@@ -9312,6 +9314,8 @@ _openshift_cli_adm_router()
93129314
local_nonpersistent_flags+=("--create")
93139315
flags+=("--default-cert=")
93149316
local_nonpersistent_flags+=("--default-cert=")
9317+
flags+=("--disable-namespace-ownership-check")
9318+
local_nonpersistent_flags+=("--disable-namespace-ownership-check")
93159319
flags+=("--dry-run")
93169320
local_nonpersistent_flags+=("--dry-run")
93179321
flags+=("--expose-metrics")
@@ -20953,6 +20957,8 @@ _openshift_infra_f5-router()
2095320957
local_nonpersistent_flags+=("--context=")
2095420958
flags+=("--denied-domains=")
2095520959
local_nonpersistent_flags+=("--denied-domains=")
20960+
flags+=("--disable-namespace-ownership-check")
20961+
local_nonpersistent_flags+=("--disable-namespace-ownership-check")
2095620962
flags+=("--f5-host=")
2095720963
local_nonpersistent_flags+=("--f5-host=")
2095820964
flags+=("--f5-http-vserver=")
@@ -21136,6 +21142,8 @@ _openshift_infra_router()
2113621142
local_nonpersistent_flags+=("--default-certificate-path=")
2113721143
flags+=("--denied-domains=")
2113821144
local_nonpersistent_flags+=("--denied-domains=")
21145+
flags+=("--disable-namespace-ownership-check")
21146+
local_nonpersistent_flags+=("--disable-namespace-ownership-check")
2113921147
flags+=("--extended-validation")
2114021148
local_nonpersistent_flags+=("--extended-validation")
2114121149
flags+=("--fields=")

docs/man/man1/oadm-router.1

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ If a router does not exist with the given name, this command will create a deplo
3535
\fB\-\-default\-cert\fP=""
3636
Optional path to a certificate file that be used as the default certificate. The file should contain the cert, key, and any CA certs necessary for the router to serve the certificate.
3737

38+
.PP
39+
\fB\-\-disable\-namespace\-ownership\-check\fP=false
40+
Disables the namespace ownership check and allows different namespaces to claim either different paths to a route host or overlapping host names in case of a wildcard route. The default behavior (false) to restrict claims to the oldest namespace that has claimed either the host or the subdomain. Please be aware that if namespace ownership checks are disabled, routes in a different namespace can use this mechanism to 'steal' sub\-paths for existing domains. This is only safe if route creation privileges are restricted, or if all the users can be trusted.
41+
3842
.PP
3943
\fB\-\-dry\-run\fP=false
4044
If true, show the result of the operation without performing it.

docs/man/man1/oc-adm-router.1

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ If a router does not exist with the given name, this command will create a deplo
3535
\fB\-\-default\-cert\fP=""
3636
Optional path to a certificate file that be used as the default certificate. The file should contain the cert, key, and any CA certs necessary for the router to serve the certificate.
3737

38+
.PP
39+
\fB\-\-disable\-namespace\-ownership\-check\fP=false
40+
Disables the namespace ownership check and allows different namespaces to claim either different paths to a route host or overlapping host names in case of a wildcard route. The default behavior (false) to restrict claims to the oldest namespace that has claimed either the host or the subdomain. Please be aware that if namespace ownership checks are disabled, routes in a different namespace can use this mechanism to 'steal' sub\-paths for existing domains. This is only safe if route creation privileges are restricted, or if all the users can be trusted.
41+
3842
.PP
3943
\fB\-\-dry\-run\fP=false
4044
If true, show the result of the operation without performing it.

docs/man/man1/openshift-admin-router.1

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ If a router does not exist with the given name, this command will create a deplo
3535
\fB\-\-default\-cert\fP=""
3636
Optional path to a certificate file that be used as the default certificate. The file should contain the cert, key, and any CA certs necessary for the router to serve the certificate.
3737

38+
.PP
39+
\fB\-\-disable\-namespace\-ownership\-check\fP=false
40+
Disables the namespace ownership check and allows different namespaces to claim either different paths to a route host or overlapping host names in case of a wildcard route. The default behavior (false) to restrict claims to the oldest namespace that has claimed either the host or the subdomain. Please be aware that if namespace ownership checks are disabled, routes in a different namespace can use this mechanism to 'steal' sub\-paths for existing domains. This is only safe if route creation privileges are restricted, or if all the users can be trusted.
41+
3842
.PP
3943
\fB\-\-dry\-run\fP=false
4044
If true, show the result of the operation without performing it.

docs/man/man1/openshift-cli-adm-router.1

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ If a router does not exist with the given name, this command will create a deplo
3535
\fB\-\-default\-cert\fP=""
3636
Optional path to a certificate file that be used as the default certificate. The file should contain the cert, key, and any CA certs necessary for the router to serve the certificate.
3737

38+
.PP
39+
\fB\-\-disable\-namespace\-ownership\-check\fP=false
40+
Disables the namespace ownership check and allows different namespaces to claim either different paths to a route host or overlapping host names in case of a wildcard route. The default behavior (false) to restrict claims to the oldest namespace that has claimed either the host or the subdomain. Please be aware that if namespace ownership checks are disabled, routes in a different namespace can use this mechanism to 'steal' sub\-paths for existing domains. This is only safe if route creation privileges are restricted, or if all the users can be trusted.
41+
3842
.PP
3943
\fB\-\-dry\-run\fP=false
4044
If true, show the result of the operation without performing it.

docs/man/man1/openshift-infra-f5-router.1

+4
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ You may restrict the set of routes exposed to a single project (with \-\-namespa
6767
\fB\-\-denied\-domains\fP=[]
6868
List of comma separated domains to deny in routes
6969

70+
.PP
71+
\fB\-\-disable\-namespace\-ownership\-check\fP=false
72+
Disables the namespace ownership checks for a route host with different paths or for overlapping host names in the case of wildcard routes. Please be aware that if namespace ownership checks are disabled, routes in a different namespace can use this mechanism to 'steal' sub\-paths for existing domains. This is only safe if route creation privileges are restricted, or if all the users can be trusted.
73+
7074
.PP
7175
\fB\-\-f5\-host\fP=""
7276
The host of F5 BIG\-IP's management interface

docs/man/man1/openshift-infra-router.1

+4
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ You may restrict the set of routes exposed to a single project (with \-\-namespa
8989
\fB\-\-denied\-domains\fP=[]
9090
List of comma separated domains to deny in routes
9191

92+
.PP
93+
\fB\-\-disable\-namespace\-ownership\-check\fP=false
94+
Disables the namespace ownership checks for a route host with different paths or for overlapping host names in the case of wildcard routes. Please be aware that if namespace ownership checks are disabled, routes in a different namespace can use this mechanism to 'steal' sub\-paths for existing domains. This is only safe if route creation privileges are restricted, or if all the users can be trusted.
95+
9296
.PP
9397
\fB\-\-extended\-validation\fP=true
9498
If set, then an additional extended validation step is performed on all routes admitted in by this router. Defaults to true and enables the extended validation checks.

pkg/cmd/admin/router/router.go

+20
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,22 @@ type RouterConfig struct {
201201
// boundaries for users and applications.
202202
ExternalHostPartitionPath string
203203

204+
// DisableNamespaceOwnershipCheck overrides the same namespace check
205+
// for different paths to a route host or for overlapping host names
206+
// in case of wildcard routes.
207+
// E.g. Setting this flag to false allows www.example.org/path1 and
208+
// www.example.org/path2 to be claimed by namespaces nsone and
209+
// nstwo respectively. And for wildcard routes, this allows
210+
// overlapping host names (*.example.test vs foo.example.test)
211+
// to be claimed by different namespaces.
212+
//
213+
// Warning: Please be aware that if namespace ownership checks are
214+
// disabled, routes in a different namespace can use this
215+
// mechanism to "steal" sub-paths for existing domains.
216+
// This is only safe if route creation privileges are
217+
// restricted, or if all the users can be trusted.
218+
DisableNamespaceOwnershipCheck bool
219+
204220
// ExposeMetrics is a hint on whether to expose metrics.
205221
ExposeMetrics bool
206222

@@ -284,6 +300,7 @@ func NewCmdRouter(f *clientcmd.Factory, parentName, name string, out, errout io.
284300
cmd.Flags().StringVar(&cfg.ExternalHostVxLANGateway, "external-host-vxlan-gw", cfg.ExternalHostVxLANGateway, "If the underlying router implementation requires VxLAN access to the pod network, this is the gateway address that should be used in cidr format.")
285301
cmd.Flags().BoolVar(&cfg.ExternalHostInsecure, "external-host-insecure", cfg.ExternalHostInsecure, "If the underlying router implementation connects with an external host over a secure connection, this causes the router to skip strict certificate verification with the external host.")
286302
cmd.Flags().StringVar(&cfg.ExternalHostPartitionPath, "external-host-partition-path", cfg.ExternalHostPartitionPath, "If the underlying router implementation uses partitions for control boundaries, this is the path to use for that partition.")
303+
cmd.Flags().BoolVar(&cfg.DisableNamespaceOwnershipCheck, "disable-namespace-ownership-check", cfg.DisableNamespaceOwnershipCheck, "Disables the namespace ownership check and allows different namespaces to claim either different paths to a route host or overlapping host names in case of a wildcard route. The default behavior (false) to restrict claims to the oldest namespace that has claimed either the host or the subdomain. Please be aware that if namespace ownership checks are disabled, routes in a different namespace can use this mechanism to 'steal' sub-paths for existing domains. This is only safe if route creation privileges are restricted, or if all the users can be trusted.")
287304

288305
cmd.MarkFlagFilename("credentials", "kubeconfig")
289306
cmd.Flags().MarkDeprecated("credentials", "use --service-account to specify the service account the router will use to make API calls")
@@ -663,6 +680,9 @@ func RunCmdRouter(f *clientcmd.Factory, cmd *cobra.Command, out, errout io.Write
663680
env["ROUTER_SUBDOMAIN"] = cfg.ForceSubdomain
664681
env["ROUTER_OVERRIDE_HOSTNAME"] = "true"
665682
}
683+
if cfg.DisableNamespaceOwnershipCheck {
684+
env["ROUTER_DISABLE_NAMESPACE_OWNERSHIP_CHECK"] = "true"
685+
}
666686
env.Add(secretEnv)
667687
if len(defaultCert) > 0 {
668688
if cfg.SecretsAsEnv {

pkg/cmd/infra/router/f5.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ func (o *F5RouterOptions) Run() error {
220220
}
221221

222222
statusPlugin := controller.NewStatusAdmitter(f5Plugin, oc, o.RouterName)
223-
uniqueHostPlugin := controller.NewUniqueHost(statusPlugin, o.RouteSelectionFunc(), statusPlugin)
224-
plugin := controller.NewHostAdmitter(uniqueHostPlugin, o.F5RouteAdmitterFunc(), false, statusPlugin)
223+
uniqueHostPlugin := controller.NewUniqueHost(statusPlugin, o.RouteSelectionFunc(), o.RouterSelection.DisableNamespaceOwnershipCheck, statusPlugin)
224+
plugin := controller.NewHostAdmitter(uniqueHostPlugin, o.F5RouteAdmitterFunc(), false, o.RouterSelection.DisableNamespaceOwnershipCheck, statusPlugin)
225225

226226
factory := o.RouterSelection.NewFactory(oc, kc)
227227
watchNodes := (len(o.InternalAddress) != 0 && len(o.VxlanGateway) != 0)

pkg/cmd/infra/router/router.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ type RouterSelection struct {
5151
AllowedDomains []string
5252
WhitelistedDomains sets.String
5353

54-
AllowWildcardRoutes bool
55-
RestrictSubdomainOwnership bool
54+
AllowWildcardRoutes bool
55+
56+
DisableNamespaceOwnershipCheck bool
5657
}
5758

5859
// Bind sets the appropriate labels
@@ -68,6 +69,7 @@ func (o *RouterSelection) Bind(flag *pflag.FlagSet) {
6869
flag.StringSliceVar(&o.DeniedDomains, "denied-domains", envVarAsStrings("ROUTER_DENIED_DOMAINS", "", ","), "List of comma separated domains to deny in routes")
6970
flag.StringSliceVar(&o.AllowedDomains, "allowed-domains", envVarAsStrings("ROUTER_ALLOWED_DOMAINS", "", ","), "List of comma separated domains to allow in routes. If specified, only the domains in this list will be allowed routes. Note that domains in the denied list take precedence over the ones in the allowed list")
7071
flag.BoolVar(&o.AllowWildcardRoutes, "allow-wildcard-routes", cmdutil.Env("ROUTER_ALLOW_WILDCARD_ROUTES", "") == "true", "Allow wildcard host names for routes")
72+
flag.BoolVar(&o.DisableNamespaceOwnershipCheck, "disable-namespace-ownership-check", cmdutil.Env("ROUTER_DISABLE_NAMESPACE_OWNERSHIP_CHECK", "") == "true", "Disables the namespace ownership checks for a route host with different paths or for overlapping host names in the case of wildcard routes. Please be aware that if namespace ownership checks are disabled, routes in a different namespace can use this mechanism to 'steal' sub-paths for existing domains. This is only safe if route creation privileges are restricted, or if all the users can be trusted.")
7173
}
7274

7375
// RouteSelectionFunc returns a func that identifies the host for a route.
@@ -204,9 +206,6 @@ func (o *RouterSelection) Complete() error {
204206
o.BlacklistedDomains = sets.NewString(o.DeniedDomains...)
205207
o.WhitelistedDomains = sets.NewString(o.AllowedDomains...)
206208

207-
// Restrict subdomains is currently enforced for wildcard routes.
208-
o.RestrictSubdomainOwnership = o.AllowWildcardRoutes
209-
210209
return nil
211210
}
212211

pkg/cmd/infra/router/template.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ func (o *TemplateRouterOptions) Run() error {
211211
if o.ExtendedValidation {
212212
nextPlugin = controller.NewExtendedValidator(nextPlugin, controller.RejectionRecorder(statusPlugin))
213213
}
214-
uniqueHostPlugin := controller.NewUniqueHost(nextPlugin, o.RouteSelectionFunc(), controller.RejectionRecorder(statusPlugin))
215-
plugin := controller.NewHostAdmitter(uniqueHostPlugin, o.RouteAdmissionFunc(), o.RestrictSubdomainOwnership, controller.RejectionRecorder(statusPlugin))
214+
uniqueHostPlugin := controller.NewUniqueHost(nextPlugin, o.RouteSelectionFunc(), o.RouterSelection.DisableNamespaceOwnershipCheck, controller.RejectionRecorder(statusPlugin))
215+
plugin := controller.NewHostAdmitter(uniqueHostPlugin, o.RouteAdmissionFunc(), o.AllowWildcardRoutes, o.RouterSelection.DisableNamespaceOwnershipCheck, controller.RejectionRecorder(statusPlugin))
216216

217217
factory := o.RouterSelection.NewFactory(oc, kc)
218218
controller := factory.Create(plugin, false)

0 commit comments

Comments
 (0)