mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 03:11:49 +08:00
feat(httpsettings): add tls auth option
- Three text areas where the user can paste in the CA Cert (optional), Client Cert and Client Key. - Tooltips for Auth checkboxes with brief descriptions of what With Credentials and With CA Cert are. - Adds popover for TLS Auth header too. - Aligns gf-form elements as labels and checkboxes were not aligned before. - Makes CA Cert optional as it is only needed for self-signed certs.
This commit is contained in:
@ -31,18 +31,18 @@ func DataProxyTransport(ds *m.DataSource) (*http.Transport, error) {
|
||||
TLSHandshakeTimeout: 10 * time.Second,
|
||||
}
|
||||
|
||||
var tlsAuth bool
|
||||
var err error
|
||||
var tlsAuth, tlsAuthWithCACert bool
|
||||
if ds.JsonData != nil {
|
||||
tlsAuth, err = ds.JsonData.Get("tlsAuth").Bool()
|
||||
tlsAuth = ds.JsonData.Get("tlsAuth").MustBool(false)
|
||||
tlsAuthWithCACert = ds.JsonData.Get("tlsAuthWithCACert").MustBool(false)
|
||||
}
|
||||
|
||||
if err == nil && tlsAuth {
|
||||
if tlsAuth {
|
||||
transport.TLSClientConfig.InsecureSkipVerify = false
|
||||
|
||||
decrypted := ds.SecureJsonData.Decrypt()
|
||||
|
||||
if len(decrypted["tlsCACert"]) > 0 {
|
||||
if tlsAuthWithCACert && len(decrypted["tlsCACert"]) > 0 {
|
||||
caPool := x509.NewCertPool()
|
||||
ok := caPool.AppendCertsFromPEM([]byte(decrypted["tlsCACert"]))
|
||||
if ok {
|
||||
|
Reference in New Issue
Block a user