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 TLS options to server #873

Merged
merged 7 commits into from
Feb 16, 2017
Merged

Add TLS options to server #873

merged 7 commits into from
Feb 16, 2017

Conversation

goller
Copy link
Contributor

@goller goller commented Feb 13, 2017

  • CHANGELOG.md updated
    • Rebased/mergable
    • Tests pass
    • Sign CLA (if not already signed)
    • Add Documentation

Connect #

The problem

Chronograf server did not have the option to host certs. This is important for OAuth2 if one doesn't have TLS termination in some other location.

The Solution

Add two CLI options (--cert and --key) and corresponding environment variables (TLS_CERTIFICATE and TLS_PRIVATE_KEY).

The two parameters specify files container the certificate and the private key. If the private key is in the certificate file then only --cert needs to be specified.

Additionally, HSTS middleware was added to require https if TLS is turned on.

@goller goller changed the title Add TLS options to server WIP (needs documentation) Add TLS options to server Feb 13, 2017
Copy link

@nathanielc nathanielc 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 to me. I just had one question.

s.Listener, err = net.Listen("tcp", net.JoinHostPort(s.Host, strconv.Itoa(s.Port)))
if s.useTLS() {
// Add HSTS to instruct all browsers to change from http to https
s.handler = HSTS(s.handler)

Choose a reason for hiding this comment

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

Does Chronograf have an API? Does this change effect the API as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @nathanielc, yup, chronograf does have an API (the swagger is here: https://github.com/influxdata/chronograf/blob/master/server/swagger.json)

The HSTS middleware also wraps the API routes as well.

Choose a reason for hiding this comment

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

Great, will non browser clients honor the HSTS headers or will you also need to create a redirect from http to https for those clients? I know nothing about HSTS so just asking the questions hoping you know the answers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, HSTS really informs the client to cache that HTTPS should be used for this domain and potentially its subdomains for a length of time.

If that client that has the value cached ever receives HTTP instead it would know to reject it as a possible man-in-the-middle.

So for normal API calls to HTTPS from, say, curl, it would not use HSTS as that value is probably not cached.

HSTS doesn't redirect HTTP to HTTPS but rather is only used on HTTPS responses.

@goller goller changed the title WIP (needs documentation) Add TLS options to server Add TLS options to server Feb 14, 2017
@goller goller requested a review from rkuchan February 14, 2017 16:38
Copy link
Contributor

@rkuchan rkuchan 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! There are two small typos and I had one minor recommendation that you can take or leave. I think the doc is clear either way.

I did wonder if the CLI options or the environment variables take precedence, but I don't know if that's relevant for this subject matter.

docs/tls.md Outdated
INFO[0000] Serving chronograf at https://[::]:8888 component=server
```

In the first log message you should `https` rather than `http`.
Copy link
Contributor

Choose a reason for hiding this comment

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

should https -> should see https

docs/tls.md Outdated
In Chronograf all command line options also have a corresponding environment
variable.

To specify the the certificate file either use the `--cert` CLI option or `TLS_CERTIFICATE`
Copy link
Contributor

Choose a reason for hiding this comment

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

duplicate the


To specify the key file either use the `--key` CLI option or `TLS_PRIVATE_KEY`
environment variable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe unnecessary but, to have all of this kind of information in one place, I might include the text below in this section, and remove If the cert and the key are in the same file, you don't have to specify the TLS_PRIVATE_KEY option from the Testing section.

To specify the certificate and key if they're in the same file either use the --cert CLI option or TLS_CERTIFICATE environment variable.

@goller goller merged commit 1265e9c into master Feb 16, 2017
@goller goller deleted the feature/tls branch February 16, 2017 15:08
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.

3 participants