mirror of
https://github.com/distribution/distribution
synced 2024-12-20 04:55:50 +01:00
fix(configuration): replace string literals with constants
Signed-off-by: vitshev <vitshev@tracto.ai>
This commit is contained in:
parent
916bdeae94
commit
328f802b8e
@ -904,6 +904,13 @@ func setFieldValue(field reflect.Value, value interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
const (
|
||||
ClientAuthRequestClientCert = "request-client-cert"
|
||||
ClientAuthRequireAnyClientCert = "require-any-client-cert"
|
||||
ClientAuthVerifyClientCertIfGiven = "verify-client-cert-if-given"
|
||||
ClientAuthRequireAndVerifyClientCert = "require-and-verify-client-cert"
|
||||
)
|
||||
|
||||
type ClientAuth string
|
||||
|
||||
// UnmarshalYAML implements the yaml.Umarshaler interface
|
||||
@ -916,10 +923,10 @@ func (clientAuth *ClientAuth) UnmarshalYAML(unmarshal func(interface{}) error) e
|
||||
}
|
||||
|
||||
switch clientAuthString {
|
||||
case "request-client-cert":
|
||||
case "require-any-client-cert":
|
||||
case "verify-client-cert-if-given":
|
||||
case "require-and-verify-client-cert":
|
||||
case ClientAuthRequestClientCert:
|
||||
case ClientAuthRequireAnyClientCert:
|
||||
case ClientAuthVerifyClientCertIfGiven:
|
||||
case ClientAuthRequireAndVerifyClientCert:
|
||||
default:
|
||||
return fmt.Errorf("invalid ClientAuth %s Must be one of: request-client-cert, require-any-client-cert, verify-client-cert-if-given, require-and-verify-client-cert", clientAuthString)
|
||||
}
|
||||
|
@ -81,10 +81,10 @@ var tlsVersions = map[string]uint16{
|
||||
|
||||
// tlsClientAuth maps user-specified values to TLS Client Authentication constants.
|
||||
var tlsClientAuth = map[string]tls.ClientAuthType{
|
||||
"request-client-cert": tls.RequestClientCert,
|
||||
"require-any-client-cert": tls.RequireAnyClientCert,
|
||||
"verify-client-cert-if-given": tls.VerifyClientCertIfGiven,
|
||||
"require-and-verify-client-cert": tls.RequireAndVerifyClientCert,
|
||||
configuration.ClientAuthRequestClientCert: tls.RequestClientCert,
|
||||
configuration.ClientAuthRequireAnyClientCert: tls.RequireAnyClientCert,
|
||||
configuration.ClientAuthVerifyClientCertIfGiven: tls.VerifyClientCertIfGiven,
|
||||
configuration.ClientAuthRequireAndVerifyClientCert: tls.RequireAndVerifyClientCert,
|
||||
}
|
||||
|
||||
// defaultLogFormatter is the default formatter to use for logs.
|
||||
|
Loading…
Reference in New Issue
Block a user