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

Togglable TLS Redirect #1322

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions core/store/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ type ConfigSchema struct {
TLSHost string `env:"CHAINLINK_TLS_HOST" `
TLSKeyPath string `env:"TLS_KEY_PATH" `
TLSPort uint16 `env:"CHAINLINK_TLS_PORT" default:"6689"`
TLSRedirect bool `env:"CHAINLINK_TLS_REDIRECT" default:"false"`
}

var configFileNotFoundError = reflect.TypeOf(viper.ConfigFileNotFoundError{})
Expand Down Expand Up @@ -334,6 +335,12 @@ func (c Config) TLSPort() uint16 {
return c.getWithFallback("TLSPort", parsePort).(uint16)
}

// TLSRedirect forces TLS redirect for unencrypted connections
func (c Config) TLSRedirect() bool {
return c.viper.GetBool(c.envVarName("TLSRedirect"))
}


// KeysDir returns the path of the keys directory (used for keystore files).
func (c Config) KeysDir() string {
return filepath.Join(c.RootDir(), "tempkeys")
Expand Down
2 changes: 1 addition & 1 deletion core/web/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func secureOptions(config store.Config) secure.Options {
return secure.Options{
FrameDeny: true,
IsDevelopment: config.Dev(),
SSLRedirect: config.TLSPort() != 0,
SSLRedirect: config.TLSRedirect(),
SSLHost: config.TLSHost(),
}
}
Expand Down