Skip to content

Commit

Permalink
Add a conf flag to enforce server certificate validation
Browse files Browse the repository at this point in the history
  • Loading branch information
aviadl committed Dec 15, 2023
1 parent e0ee921 commit 8f2119d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
12 changes: 6 additions & 6 deletions descope/api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -787,11 +787,11 @@ type sdkInfo struct {
}

type ClientParams struct {
BaseURL string
DefaultClient IHttpClient
CustomDefaultHeaders map[string]string

ProjectID string
BaseURL string
DefaultClient IHttpClient
CustomDefaultHeaders map[string]string
VerifyServerCertificate bool
ProjectID string
}

type IHttpClient interface {
Expand Down Expand Up @@ -826,7 +826,7 @@ func NewClient(conf ClientParams) *Client {
t.MaxIdleConns = 100
t.MaxConnsPerHost = 100
t.MaxIdleConnsPerHost = 100
t.TLSClientConfig.InsecureSkipVerify = true
t.TLSClientConfig.InsecureSkipVerify = !conf.VerifyServerCertificate
httpClient = &http.Client{
Timeout: time.Second * 10,
Transport: t,
Expand Down
2 changes: 1 addition & 1 deletion descope/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func NewWithConfig(config *Config) (*DescopeClient, error) {
}
config.setManagementKey()

c := api.NewClient(api.ClientParams{BaseURL: config.DescopeBaseURL, CustomDefaultHeaders: config.CustomDefaultHeaders, DefaultClient: config.DefaultClient, ProjectID: config.ProjectID})
c := api.NewClient(api.ClientParams{BaseURL: config.DescopeBaseURL, CustomDefaultHeaders: config.CustomDefaultHeaders, DefaultClient: config.DefaultClient, ProjectID: config.ProjectID, VerifyServerCertificate: config.VerifyServerCertificate})

authService, err := auth.NewAuth(auth.AuthParams{
ProjectID: config.ProjectID,
Expand Down
2 changes: 2 additions & 0 deletions descope/client/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ type Config struct {
DescopeBaseURL string
// DefaultClient (optional, http.DefaultClient) - override the default client used to Do the actual http request.
DefaultClient api.IHttpClient
// VerifyServerCertificate (optional) - verify the server certificate
VerifyServerCertificate bool
// CustomDefaultHeaders (optional, nil) - add custom headers to all requests used to communicate with descope services.
CustomDefaultHeaders map[string]string
// LogLevel (optional, LogNone) - set a log level (Debug/Info/None) for the sdk to use when logging.
Expand Down

0 comments on commit 8f2119d

Please sign in to comment.