Skip to content
This repository has been archived by the owner on Jan 27, 2022. It is now read-only.

KOGITO-5715: Online DMN Editor should support deployment to any Openshift Cluster other than Dev Sandbox #21

Merged
merged 1 commit into from Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/launch.json
Expand Up @@ -9,7 +9,8 @@
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}"
"program": "main.go",
"showLog": true
}
]
}
2 changes: 2 additions & 0 deletions go.mod
Expand Up @@ -3,9 +3,11 @@ module github.com/kiegroup/kogito-tooling-go
go 1.16

require (
github.com/cratonica/2goarray v0.0.0-20190331194516-514510793eaa // indirect
github.com/getlantern/systray v1.1.0
github.com/gorilla/mux v1.8.0
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
github.com/rs/cors v1.7.0 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
gopkg.in/yaml.v2 v2.4.0
)
12 changes: 12 additions & 0 deletions go.sum
@@ -1,3 +1,5 @@
github.com/cratonica/2goarray v0.0.0-20190331194516-514510793eaa h1:Wg+722vs7a2zQH5lR9QWYsVbplKeffaQFIs5FTdfNNo=
github.com/cratonica/2goarray v0.0.0-20190331194516-514510793eaa/go.mod h1:6Arca19mRx58CA7OWEd7Wu1NpC1rd3uDnNs6s1pj/DI=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520 h1:NRUJuo3v3WGC/g5YiyF790gut6oQr5f3FBI88Wv0dx4=
Expand Down Expand Up @@ -29,8 +31,18 @@ github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ=
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9 h1:YTzHMGlqJu67/uEo1lBv0n3wBXhXNeUbB1XfN2vmTm0=
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
Expand Down
20 changes: 20 additions & 0 deletions pkg/kogito/server.go
Expand Up @@ -3,6 +3,8 @@ package kogito
import (
"bufio"
"context"
"crypto/tls"
"net"

"encoding/json"
"fmt"
Expand Down Expand Up @@ -197,6 +199,24 @@ func devSandboxHandler() func(w http.ResponseWriter, r *http.Request) {
r.Host = r.URL.Host

proxy := httputil.NewSingleHostReverseProxy(targetUrl)

// tolerate self-signed certificates
proxy.Transport = &http.Transport{
Proxy: http.ProxyFromEnvironment,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe we set any env variable that can be used by ProxyFromEnvironment, so I'm not sure if this line is being used. https://pkg.go.dev/net/http#ProxyFromEnvironment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ljmotta . Neither am I :-) But I realized that if we don't set this the default value will be nil. Anyway, this would only affect users that have (rely on) some proxy (to access the Internet) configured in the system environment (OS level). Not sure...

DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).DialContext,
ForceAttemptHTTP2: true,
MaxIdleConns: 10,
IdleConnTimeout: 60 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
Copy link
Collaborator

@ljmotta ljmotta Aug 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This creates a security issue as described in the docs. I think asking the user if he wants to disable this check would be a better solution, WDYT? For now, it's not a problem, so I can create a JIRA to add this functionality eventually.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I understand. I believe the right way is to have this parameterized. Maye adding an option to config the service from the System Tray. Without this setting, the service can't connect to Openshift Cluster that uses self-signed certificates.

},
}

proxy.ModifyResponse = func(resp *http.Response) error {
resp.Header.Add("Access-Control-Allow-Origin", "*")
resp.Header.Add("Access-Control-Allow-Methods", "*")
Expand Down