|
|
@ -268,7 +268,7 @@ func LoginOptPlainText(isPlainText bool) LoginOption {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func ensureTLSConfig(client *auth.Client) (*tls.Config, error) {
|
|
|
|
func ensureTLSConfig(client *auth.Client, setConfig *tls.Config) (*tls.Config, error) {
|
|
|
|
var transport *http.Transport
|
|
|
|
var transport *http.Transport
|
|
|
|
|
|
|
|
|
|
|
|
switch t := client.Client.Transport.(type) {
|
|
|
|
switch t := client.Client.Transport.(type) {
|
|
|
@ -292,7 +292,10 @@ func ensureTLSConfig(client *auth.Client) (*tls.Config, error) {
|
|
|
|
return nil, fmt.Errorf("unable to access TLS client configuration, the provided HTTP Transport is not supported, given: %T", client.Client.Transport)
|
|
|
|
return nil, fmt.Errorf("unable to access TLS client configuration, the provided HTTP Transport is not supported, given: %T", client.Client.Transport)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if transport.TLSClientConfig == nil {
|
|
|
|
switch {
|
|
|
|
|
|
|
|
case setConfig != nil:
|
|
|
|
|
|
|
|
transport.TLSClientConfig = setConfig
|
|
|
|
|
|
|
|
case transport.TLSClientConfig == nil:
|
|
|
|
transport.TLSClientConfig = &tls.Config{}
|
|
|
|
transport.TLSClientConfig = &tls.Config{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -302,7 +305,7 @@ func ensureTLSConfig(client *auth.Client) (*tls.Config, error) {
|
|
|
|
// LoginOptInsecure returns a function that sets the insecure setting on login
|
|
|
|
// LoginOptInsecure returns a function that sets the insecure setting on login
|
|
|
|
func LoginOptInsecure(insecure bool) LoginOption {
|
|
|
|
func LoginOptInsecure(insecure bool) LoginOption {
|
|
|
|
return func(o *loginOperation) {
|
|
|
|
return func(o *loginOperation) {
|
|
|
|
tlsConfig, err := ensureTLSConfig(o.client.authorizer)
|
|
|
|
tlsConfig, err := ensureTLSConfig(o.client.authorizer, nil)
|
|
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
panic(err)
|
|
|
@ -318,7 +321,7 @@ func LoginOptTLSClientConfig(certFile, keyFile, caFile string) LoginOption {
|
|
|
|
if (certFile == "" || keyFile == "") && caFile == "" {
|
|
|
|
if (certFile == "" || keyFile == "") && caFile == "" {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tlsConfig, err := ensureTLSConfig(o.client.authorizer)
|
|
|
|
tlsConfig, err := ensureTLSConfig(o.client.authorizer, nil)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -345,6 +348,17 @@ func LoginOptTLSClientConfig(certFile, keyFile, caFile string) LoginOption {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// LoginOptTLSClientConfigFromConfig returns a function that sets the TLS settings on login
|
|
|
|
|
|
|
|
// receiving the configuration in memory rather than from files.
|
|
|
|
|
|
|
|
func LoginOptTLSClientConfigFromConfig(conf *tls.Config) LoginOption {
|
|
|
|
|
|
|
|
return func(o *loginOperation) {
|
|
|
|
|
|
|
|
_, err := ensureTLSConfig(o.client.authorizer, conf)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
panic(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type (
|
|
|
|
type (
|
|
|
|
// LogoutOption allows specifying various settings on logout
|
|
|
|
// LogoutOption allows specifying various settings on logout
|
|
|
|
LogoutOption func(*logoutOperation)
|
|
|
|
LogoutOption func(*logoutOperation)
|
|
|
|