Skip to content

Commit

Permalink
Merge pull request #13592 from openshift-cherrypick-robot/cherry-pick…
Browse files Browse the repository at this point in the history
…-13175-to-release-4.14

[release-4.14] OCPBUGS-29239: Add a new allowInsecure option to the internet proxy
  • Loading branch information
openshift-merge-bot[bot] committed Feb 8, 2024
2 parents 3cab6c4 + 06e94cd commit 2bf9f6c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions frontend/packages/console-shared/src/utils/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { HttpError } from '@console/dynamic-plugin-sdk/src/utils/error/http-erro
export const API_PROXY_URL = '/api/dev-console/proxy/internet';

type ProxyRequest = {
allowInsecure?: boolean;
method: string;
url: string;
headers?: Record<string, string[]>;
Expand Down
13 changes: 12 additions & 1 deletion pkg/devconsole/proxy/proxy.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package proxy

import (
"crypto/tls"
"encoding/json"
"fmt"
"io"
Expand Down Expand Up @@ -69,7 +70,17 @@ func serve(r *http.Request) (ProxyResponse, error) {
}
serviceRequest.URL.RawQuery = query.Encode()

serviceClient := &http.Client{}
var serviceClient *http.Client
if request.AllowInsecure {
serviceTransport := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
serviceClient = &http.Client{
Transport: serviceTransport,
}
} else {
serviceClient = &http.Client{}
}

serviceResponse, err := serviceClient.Do(serviceRequest)
if err != nil {
Expand Down
11 changes: 6 additions & 5 deletions pkg/devconsole/proxy/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
)

type ProxyRequest struct {
Method string `json:"method"`
Url string `json:"url"`
Headers http.Header `json:"headers"`
Queryparams url.Values `json:"queryparams"`
Body string `json:"body"`
AllowInsecure bool `json:"allowInsecure,omitempty"`
Method string `json:"method"`
Url string `json:"url"`
Headers http.Header `json:"headers"`
Queryparams url.Values `json:"queryparams"`
Body string `json:"body"`
}

type ProxyResponse struct {
Expand Down

0 comments on commit 2bf9f6c

Please sign in to comment.