Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit 6280433

Browse files
tcdowneycwlbraa
andcommitted
stop sending basic auth in staging completion callback in cf-for-k8s
This is secured by NetworkPolicy and Istio AuthorizationPolicy in cf-for-k8s - https://github.com/cloudfoundry/cf-for-k8s/blob/b5cd28db499009ab9ecbfbe30e77073938f8be39/config/networking/network-policies.yaml#L318-L339 - https://github.com/cloudfoundry/cf-for-k8s/blob/b5cd28db499009ab9ecbfbe30e77073938f8be39/config/networking/istio-authorization-policies.yml#L18-L38 [#175080278](https://www.pivotaltracker.com/story/show/175080278) Co-authored-by: Tim Downey <tdowney@vmware.com> Co-authored-by: Connor Braa <cbraa@pivotal.io>
1 parent 68aa90a commit 6280433

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

lib/cloud_controller/opi/stager_client.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,18 @@ def get_lifecycle(staging_details, staging_guid, action_builder)
118118

119119
def staging_completion_callback(staging_details)
120120
if config.kubernetes_api_configured?
121-
port = config.get(:internal_service_port)
121+
port = config.get(:internal_service_port)
122+
auth = '' # on Kubernetes we are relying on NetworkPolicy and Istio AuthorizationPolicy for authz
122123
scheme = 'http'
123124
else
124-
port = config.get(:tls_port)
125+
port = config.get(:tls_port)
126+
auth = "#{config.get(:internal_api, :auth_user)}:#{CGI.escape(config.get(:internal_api, :auth_password))}@"
125127
scheme = 'https'
126128
end
127129

128-
auth = "#{config.get(:internal_api, :auth_user)}:#{CGI.escape(config.get(:internal_api, :auth_password))}"
129130
host_port = "#{config.get(:internal_service_hostname)}:#{port}"
130131
path = "/internal/v3/staging/#{staging_details.staging_guid}/build_completed?start=#{staging_details.start_after_staging}"
131-
"#{scheme}://#{auth}@#{host_port}#{path}"
132+
"#{scheme}://#{auth}#{host_port}#{path}"
132133
end
133134

134135
def build_env(environment)

spec/unit/lib/cloud_controller/opi/stager_client_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@
201201
stager_client.stage(staging_guid, staging_details)
202202
expect(WebMock).to have_requested(:post, "#{eirini_url}/stage/#{staging_guid}").with { |req|
203203
parsed_json = JSON.parse(req.body)
204-
parsed_json['completion_callback'] == 'http://internal_user:internal_password@api.internal.cf:9090/internal/v3/staging/some_staging_guid/build_completed?start='
204+
parsed_json['completion_callback'] == 'http://api.internal.cf:9090/internal/v3/staging/some_staging_guid/build_completed?start='
205205
}
206206
end
207207
end

0 commit comments

Comments
 (0)