Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add secure socks proxy to sdk #667

Merged
merged 11 commits into from
Apr 6, 2023
Merged

Conversation

stephaniehingtgen
Copy link
Contributor

@stephaniehingtgen stephaniehingtgen commented Apr 3, 2023

What this PR does / why we need it:

Grafana users need to be able to connect to datasources that live in different networks than where Grafana is running. This PR adds new functionality that allows datasources to connect through a socks5 proxy with TLS. This will only be available to users if it is enabled on the instance (via the config.ini: secure_socks_datasource_proxy.enabled) and the datasource has enableSecureSocksProxy=true set in the json data. Optionally, datasources may specify different usernames and passwords to connect to the proxy.

Which issue(s) this PR fixes:

Relates to grafana/grafana#15045
Closes https://github.com/grafana/hosted-grafana/issues/3369

Special notes for your reviewer:

  • This functionality has already been running in Grafana, under a feature toggle, and now we're ready to move it into the sdk without a feature toggle (see HTTP PR and SQL PR).
  • PR is up for adding the env variables to Grafana, but we'll need to update the sdk version in Grafana before it will work
  • See draft PR of using this in Grafana's core datasources. At first, to accomodate the core datasources, I had added a config that could be passed in to the sdk, but it seemed cleaner to just set the needed environment variables in Grafana itself (diff). I'm happy to change it back to that, though, if that is better.

@stephaniehingtgen stephaniehingtgen requested a review from a team as a code owner April 3, 2023 22:35
@stephaniehingtgen stephaniehingtgen requested review from wbrowne and andresmgot and removed request for a team April 3, 2023 22:35
@CLAassistant
Copy link

CLAassistant commented Apr 3, 2023

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Member

@marefr marefr left a comment

Choose a reason for hiding this comment

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

Looks good. Just some minor things left

backend/proxy/secure_socks_proxy.go Show resolved Hide resolved
backend/proxy/secure_socks_proxy.go Show resolved Hide resolved
Copy link
Contributor

@andresmgot andresmgot left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 12 to 15
var DefaultOptions = Options{
Timeout: 180 * time.Second,
KeepAlive: 30 * time.Second,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you could use the DefaultTimeoutOptions from the httpclient package (there the timeout is 30s, not 180)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For sure! Updated

Copy link
Member

@marefr marefr left a comment

Choose a reason for hiding this comment

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

LGTM great. Agree with Andres suggestion

Copy link
Member

@xnyo xnyo left a comment

Choose a reason for hiding this comment

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

Great work! Just one small thing:

backend/http_settings.go Outdated Show resolved Hide resolved
Copy link
Member

@marefr marefr left a comment

Choose a reason for hiding this comment

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

Looks great. Some minor comments/nits

backend/proxy/options.go Outdated Show resolved Hide resolved
backend/proxy/secure_socks_proxy.go Show resolved Hide resolved
backend/httpclient/http_client.go Outdated Show resolved Hide resolved
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Copy link
Member

@marefr marefr left a comment

Choose a reason for hiding this comment

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

LGTM great

@stephaniehingtgen stephaniehingtgen merged commit 9e36be7 into main Apr 6, 2023
@stephaniehingtgen stephaniehingtgen deleted the add-secure-socks-proxy-to-sdk branch April 6, 2023 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants