Skip to content

Commit 87c06e1

Browse files
authored
Merge branch 'develop' into disable-tcp-router
2 parents 524d8e8 + 93b7311 commit 87c06e1

File tree

12 files changed

+352
-113
lines changed

12 files changed

+352
-113
lines changed

.final_builds/packages/golang-1.24-linux/index.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ builds:
33
version: 4cb5a37cbce65d7f724843664959f99b3a43432a56099aeca3bb999dff9e4e99
44
blobstore_id: 0040560a-0c3a-48aa-655f-976b8098d3e4
55
sha1: sha256:cb1cdf8f4018cad43e9ee47ef455db2b1792f6381953d784dad69f709c3b759e
6+
527ba0d0e2133f59ca19e7407072b229407374fbff29c5d7f4cbfeb950157f07:
7+
version: 527ba0d0e2133f59ca19e7407072b229407374fbff29c5d7f4cbfeb950157f07
8+
blobstore_id: 2758e3b2-0441-45c7-4728-556bd4db33c4
9+
sha1: sha256:1de2afcd78735f842f28457710b869c296881183921c5659670be922fa16554b
610
7e16dacbe34be58aa80f17d6f9626d3668282accb2d859ccb13675710dccac31:
711
version: 7e16dacbe34be58aa80f17d6f9626d3668282accb2d859ccb13675710dccac31
812
blobstore_id: 63e82092-fdb7-44ba-5b33-af41ef843613

docs/01-route-registrar-usage.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ The route-registrar expects a configuration json file like the one below:
8484
- `route_service_url` is optional. When provided, Gorouter will proxy
8585
requests received for the `uris` above to this address.
8686
- `health_check` is optional and explained in more detail below.
87+
- `sni_routable_san` is the SAN used to route the request to the appropriate
88+
backend. Required when `type` is `sni` and `terminate_frontend_tls` is enabled.
8789
- `terminate_frontend_tls` is optional. When true, the router will terminate
8890
TLS before forwarding the requests to the backend servers. Default: false
8991
- `enable_backend_tls` is optional. When true, the router will initiate a

jobs/route_registrar/spec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ properties:
130130
options (optional, object, for http routes): Custom per-route options
131131
terminate_frontend_tls (optional, boolean): When true, the router will terminate TLS before forwarding requests to the backend. Default: false
132132
alpns (optional, array): Application Layer Protocol Negotiation strings.
133+
sni_routable_san(optional, string): is the SAN used to route the request to the appropriate backend.
134+
Required when `type` is `sni` and `terminate_frontend_tls` is enabled.
133135

134136
health_check object
135137
name (required, string): Human-readable reference for the healthcheck

jobs/route_registrar/templates/registrar_settings.json.erb

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ TEXT
5454
end
5555

5656
message_bus_servers = nil
57-
if nats_user and nats_password
57+
if nats_user && nats_password
5858
message_bus_servers = nats_machines.map do |host|
5959
{
6060
host: "#{host}:#{nats_port}",
@@ -91,7 +91,17 @@ TEXT
9191
route['uris'].map! { |uri| "#{spec.index}-#{uri}" }
9292
end
9393

94-
if route['type'] == 'sni'
94+
if route['type'] == 'sni' && route['terminate_frontend_tls']
95+
if route['sni_routable_san'] == nil || route['sni_routable_san'] == ''
96+
raise "route_registrar.routes[#{index}].route.sni_routable_san must be provided when type is sni and terminate_frontend_tls is enabled"
97+
end
98+
end
99+
100+
if route['type'] == 'sni' && !route['terminate_frontend_tls']
101+
if route['sni_routable_san'] != nil
102+
raise "route_registrar.routes[#{index}].route.sni_routable_san cannot be provided when type is sni and terminate_frontend_tls is disabled"
103+
end
104+
95105
route['sni_routable_san'] = spec.address
96106

97107
if route.key?('server_cert_domain_name_modifier')
@@ -142,7 +152,7 @@ TEXT
142152
end
143153

144154
link.if_p('routing_api.enabled_api_endpoints') do |endpoints|
145-
if endpoints == 'both' or endpoints == 'mtls'
155+
if endpoints == 'both' || endpoints == 'mtls'
146156
api_scheme = 'https'
147157
api_port = link.p('routing_api.tls_port', api_port)
148158
end
@@ -156,7 +166,7 @@ TEXT
156166

157167
if_p('route_registrar.routing_api.api_url') do |prop|
158168
if_link('routing_api') do |link|
159-
if link.p('routing_api.enabled_api_endpoints') == "mtls" and not prop.start_with?('https')
169+
if link.p('routing_api.enabled_api_endpoints') == "mtls" && !prop.start_with?('https')
160170
raise 'expected route_registrar.routing_api.api_url to be https when routing_api.enabled_api_endpoints is mtls only'
161171
end
162172
end
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/bin/bash -e
22
<% unless p("tcp_router.disable") %>
3-
# pre-start
4-
<% if spec.bootstrap == true %>
3+
# This pre-start script runs (1) config validation and (2) creates frontend certs on the VM (if any)
54
/var/vcap/packages/tcp_router/bin/config-validator -config /var/vcap/jobs/tcp_router/config/tcp_router.yml -enable-cert-creation true
65
<% end %>
7-
<% end %>
6+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
name: golang-1.24-linux
2-
fingerprint: a90cc272bb527c55616cdc8aee918f0bf63838d3a3f3f1a223566a8b3da020ee
2+
fingerprint: 527ba0d0e2133f59ca19e7407072b229407374fbff29c5d7f4cbfeb950157f07

spec/route_registar_templates_spec.rb

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@
4141
}
4242
end
4343

44+
let(:sni_route) { {
45+
"name" => "svc-name",
46+
"registration_interval" => "20s",
47+
"router_group" => "svc-router-group",
48+
"external_port" => 1024,
49+
"type" => "sni",
50+
"sni_port" => 5671,
51+
"sni_routable_san" => "svc-1.foobar.com",
52+
"terminate_frontend_tls" => true,
53+
"enable_backend_tls" => true
54+
} }
55+
4456
describe 'config/routing_api/certs/client.crt' do
4557
let(:template) { job.template('config/routing_api/certs/client.crt') }
4658
let(:links) do
@@ -492,7 +504,7 @@
492504
context 'when uaa.tls_port is provided in the link' do
493505
let(:uaa_link_properties) do
494506
{
495-
'tls_port' => 9443,
507+
'tls_port' => 9443,
496508
}
497509
end
498510
it 'uses the link value' do
@@ -511,7 +523,7 @@
511523
context 'when uaa.token_endpoint is provided in the link' do
512524
let(:uaa_link_properties) do
513525
{
514-
'token_endpoint' => 'link-uaa.service.cf.internal',
526+
'token_endpoint' => 'link-uaa.service.cf.internal',
515527
}
516528
end
517529
it 'uses the link value' do
@@ -681,6 +693,56 @@
681693
end
682694
end
683695

696+
describe 'when type is sni and frontend_tls is enabled and sni_routable_san is provided' do
697+
before do
698+
merged_manifest_properties['route_registrar']['routes'][0] = sni_route
699+
merged_manifest_properties['nats'] = { 'fail_if_using_nats_without_tls' => false }
700+
end
701+
702+
it 'should use the provided sni_routable_san' do
703+
rendered_hash = JSON.parse(template.render(merged_manifest_properties, consumes: links))
704+
expect(rendered_hash['routes'][0]).to eq({
705+
"name" => "svc-name",
706+
"registration_interval" => "20s",
707+
"router_group" => "svc-router-group",
708+
"external_port" => 1024,
709+
"type" => "sni",
710+
"sni_port" => 5671,
711+
"sni_routable_san" => "svc-1.foobar.com",
712+
"terminate_frontend_tls" => true,
713+
"enable_backend_tls" => true
714+
})
715+
end
716+
end
717+
718+
describe 'when type is sni and frontend_tls is disabled and sni_routable_san is provided' do
719+
before do
720+
merged_manifest_properties['route_registrar']['routes'][0] = sni_route
721+
merged_manifest_properties['route_registrar']['routes'][0]['terminate_frontend_tls'] = false
722+
merged_manifest_properties['nats'] = { 'fail_if_using_nats_without_tls' => false }
723+
end
724+
725+
it 'raises an error for invalid sni_routable_san' do
726+
expect { template.render(merged_manifest_properties, consumes: links) }.to raise_error(
727+
RuntimeError, 'route_registrar.routes[0].route.sni_routable_san cannot be provided when type is sni and terminate_frontend_tls is disabled'
728+
)
729+
end
730+
end
731+
732+
describe 'when type is sni and frontend_tls is enabled and sni_routable_san is NOT provided' do
733+
before do
734+
merged_manifest_properties['route_registrar']['routes'][0] = sni_route
735+
merged_manifest_properties['route_registrar']['routes'][0]['sni_routable_san'] = ''
736+
merged_manifest_properties['nats'] = { 'fail_if_using_nats_without_tls' => false }
737+
end
738+
739+
it 'raises an error for invalid sni_routable_san' do
740+
expect { template.render(merged_manifest_properties, consumes: links) }.to raise_error(
741+
RuntimeError, 'route_registrar.routes[0].route.sni_routable_san must be provided when type is sni and terminate_frontend_tls is enabled'
742+
)
743+
end
744+
end
745+
684746
describe 'when tls is not enabled and the san is not provided' do
685747
before do
686748
merged_manifest_properties['route_registrar']['routes'][0].delete('tls_port')

0 commit comments

Comments
 (0)