Skip to content

Commit

Permalink
Remove inscure tls option for quota client (#568)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJCross authored Apr 20, 2022
1 parent 9767d64 commit deb50f4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/autoscaler/api/brokerserver/broker_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func NewBrokerHandler(logger lager.Logger, conf *config.Config, bindingdb db.Bin
catalog: catalog,
policyValidator: policyvalidator.NewPolicyValidator(conf.PolicySchemaPath, conf.ScalingRules.CPU.LowerThreshold, conf.ScalingRules.CPU.UpperThreshold),
schedulerUtil: schedulerutil.NewSchedulerUtil(conf, logger),
quotaManagementClient: quota.NewClient(conf, logger, cfClient),
quotaManagementClient: quota.NewClient(conf, logger),
planChecker: plancheck.NewPlanChecker(conf.PlanCheck, logger),
cfClient: cfClient,
credentials: credentials,
Expand Down
11 changes: 3 additions & 8 deletions src/autoscaler/api/quota/quota_management_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package quota

import (
"context"
"crypto/tls"
"encoding/json"
"fmt"
"net"
Expand All @@ -24,14 +23,14 @@ type Client struct {
logger lager.Logger
}

func NewClient(config *config.Config, logger lager.Logger, cfClient cf.CFClient) *Client {
func NewClient(config *config.Config, logger lager.Logger) *Client {
qmc := &Client{conf: config, logger: logger.Session("quota-management-client")}

if config.QuotaManagement != nil {
qmc.logger.Info("creating-client")
hc := &http.Client{
Timeout: 15 * time.Second,
Transport: newTransport(true),
Transport: newTransport(),
}
ctx := context.WithValue(context.Background(), oauth2.HTTPClient, hc)
conf := &clientcredentials.Config{ClientID: config.QuotaManagement.ClientID, ClientSecret: config.QuotaManagement.Secret, TokenURL: config.QuotaManagement.TokenURL}
Expand All @@ -41,22 +40,18 @@ func NewClient(config *config.Config, logger lager.Logger, cfClient cf.CFClient)
return qmc
}

func newTransport(shouldSkipTLSValidation bool) *http.Transport {
func newTransport() *http.Transport {
return &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 5 * time.Second,
KeepAlive: 30 * time.Second,
DualStack: true,
}).DialContext,
ForceAttemptHTTP2: true,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 5 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
//TODO we should not be turning of SkipSSLValidation on the default transport
//#nosec G402
TLSClientConfig: &tls.Config{InsecureSkipVerify: shouldSkipTLSValidation},
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/autoscaler/api/quota/quota_management_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var _ = Describe("Quota", func() {
Context("GetQuota", func() {
Context("when not configured", func() {
BeforeEach(func() {
qmc = quota.NewClient(quotaConfig, lagertest.NewTestLogger("Quota"), nil)
qmc = quota.NewClient(quotaConfig, lagertest.NewTestLogger("Quota"))
})
It("returns -1", func() {
quotaSize, err = qmc.GetQuota("test-org", "test-service", "test-plan")
Expand All @@ -40,7 +40,7 @@ var _ = Describe("Quota", func() {
quotaServer = ghttp.NewServer()
quotaConfig.QuotaManagement = &config.QuotaManagementConfig{}
quotaConfig.QuotaManagement.API = quotaServer.URL()
qmc = quota.NewClient(quotaConfig, lagertest.NewTestLogger("Quota"), nil)
qmc = quota.NewClient(quotaConfig, lagertest.NewTestLogger("Quota"))
qmc.SetClient(&http.Client{})

quotaServer.AppendHandlers(
Expand Down

0 comments on commit deb50f4

Please sign in to comment.