mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2026-10-21 01:58:29 +02:00
Added ability to specify allowed TLS cipher suites.
This commit is contained in:
@@ -447,15 +447,16 @@ func getXAuthRequestAccessTokenHeader() Header {
|
||||
}
|
||||
|
||||
type LegacyServer struct {
|
||||
MetricsAddress string `flag:"metrics-address" cfg:"metrics_address"`
|
||||
MetricsSecureAddress string `flag:"metrics-secure-address" cfg:"metrics_secure_address"`
|
||||
MetricsTLSCertFile string `flag:"metrics-tls-cert-file" cfg:"metrics_tls_cert_file"`
|
||||
MetricsTLSKeyFile string `flag:"metrics-tls-key-file" cfg:"metrics_tls_key_file"`
|
||||
HTTPAddress string `flag:"http-address" cfg:"http_address"`
|
||||
HTTPSAddress string `flag:"https-address" cfg:"https_address"`
|
||||
TLSCertFile string `flag:"tls-cert-file" cfg:"tls_cert_file"`
|
||||
TLSKeyFile string `flag:"tls-key-file" cfg:"tls_key_file"`
|
||||
TLSMinVersion string `flag:"tls-min-version" cfg:"tls_min_version"`
|
||||
MetricsAddress string `flag:"metrics-address" cfg:"metrics_address"`
|
||||
MetricsSecureAddress string `flag:"metrics-secure-address" cfg:"metrics_secure_address"`
|
||||
MetricsTLSCertFile string `flag:"metrics-tls-cert-file" cfg:"metrics_tls_cert_file"`
|
||||
MetricsTLSKeyFile string `flag:"metrics-tls-key-file" cfg:"metrics_tls_key_file"`
|
||||
HTTPAddress string `flag:"http-address" cfg:"http_address"`
|
||||
HTTPSAddress string `flag:"https-address" cfg:"https_address"`
|
||||
TLSCertFile string `flag:"tls-cert-file" cfg:"tls_cert_file"`
|
||||
TLSKeyFile string `flag:"tls-key-file" cfg:"tls_key_file"`
|
||||
TLSMinVersion string `flag:"tls-min-version" cfg:"tls_min_version"`
|
||||
TLSCipherSuites []string `flag:"tls-cipher-suite" cfg:"tls_cipher_suites"`
|
||||
}
|
||||
|
||||
func legacyServerFlagset() *pflag.FlagSet {
|
||||
@@ -470,6 +471,7 @@ func legacyServerFlagset() *pflag.FlagSet {
|
||||
flagSet.String("tls-cert-file", "", "path to certificate file")
|
||||
flagSet.String("tls-key-file", "", "path to private key file")
|
||||
flagSet.String("tls-min-version", "", "minimal TLS version for HTTPS clients (either \"TLS1.2\" or \"TLS1.3\")")
|
||||
flagSet.StringSlice("tls-cipher-suite", []string{}, "restricts TLS cipher suites to those listed (e.g. TLS_RSA_WITH_RC4_128_SHA) (may be given multiple times)")
|
||||
|
||||
return flagSet
|
||||
}
|
||||
@@ -600,6 +602,9 @@ func (l LegacyServer) convert() (Server, Server) {
|
||||
},
|
||||
MinVersion: l.TLSMinVersion,
|
||||
}
|
||||
if len(l.TLSCipherSuites) != 0 {
|
||||
appServer.TLS.CipherSuites = l.TLSCipherSuites
|
||||
}
|
||||
// Preserve backwards compatibility, only run one server
|
||||
appServer.BindAddress = ""
|
||||
} else {
|
||||
|
||||
@@ -804,6 +804,7 @@ var _ = Describe("Legacy Options", func() {
|
||||
keyPath = "tls.key"
|
||||
minVersion = "TLS1.3"
|
||||
)
|
||||
cipherSuites := []string{"TLS_RSA_WITH_AES_128_GCM_SHA256", "TLS_RSA_WITH_AES_256_GCM_SHA384"}
|
||||
|
||||
var tlsConfig = &TLS{
|
||||
Cert: &SecretSource{
|
||||
@@ -820,6 +821,15 @@ var _ = Describe("Legacy Options", func() {
|
||||
MinVersion: minVersion,
|
||||
}
|
||||
|
||||
var tlsConfigCipherSuites = &TLS{
|
||||
Cert: tlsConfig.Cert,
|
||||
Key: tlsConfig.Key,
|
||||
CipherSuites: []string{
|
||||
"TLS_RSA_WITH_AES_128_GCM_SHA256",
|
||||
"TLS_RSA_WITH_AES_256_GCM_SHA384",
|
||||
},
|
||||
}
|
||||
|
||||
DescribeTable("should convert to app and metrics servers",
|
||||
func(in legacyServersTableInput) {
|
||||
appServer, metricsServer := in.legacyServer.convert()
|
||||
@@ -860,6 +870,19 @@ var _ = Describe("Legacy Options", func() {
|
||||
TLS: tlsConfigMinVersion,
|
||||
},
|
||||
}),
|
||||
Entry("with TLS options specified with CipherSuites", legacyServersTableInput{
|
||||
legacyServer: LegacyServer{
|
||||
HTTPAddress: insecureAddr,
|
||||
HTTPSAddress: secureAddr,
|
||||
TLSKeyFile: keyPath,
|
||||
TLSCertFile: crtPath,
|
||||
TLSCipherSuites: cipherSuites,
|
||||
},
|
||||
expectedAppServer: Server{
|
||||
SecureBindAddress: secureAddr,
|
||||
TLS: tlsConfigCipherSuites,
|
||||
},
|
||||
}),
|
||||
Entry("with metrics HTTP and HTTPS addresses", legacyServersTableInput{
|
||||
legacyServer: LegacyServer{
|
||||
HTTPAddress: insecureAddr,
|
||||
|
||||
@@ -29,4 +29,12 @@ type TLS struct {
|
||||
// MinVersion is the minimal TLS version that is acceptable.
|
||||
// E.g. Set to "TLS1.3" to select TLS version 1.3
|
||||
MinVersion string
|
||||
|
||||
// CipherSuites is a list of TLS cipher suites that are allowed.
|
||||
// E.g.:
|
||||
// - TLS_RSA_WITH_RC4_128_SHA
|
||||
// - TLS_RSA_WITH_AES_256_GCM_SHA384
|
||||
// If not specified, the default Go safe cipher list is used.
|
||||
// List of valid cipher suites can be found in the [crypto/tls documentation](https://pkg.go.dev/crypto/tls#pkg-constants).
|
||||
CipherSuites []string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user