Browse Source

Retain old name for TLS client auth

I renamed `tlsAuth` to `tlsClientAuth` to better describe the fact that
this variable is used to enable TLS client authentication (as opposed to
server authentication) in c04d95f35.

However, changing the name breaks backwards compatibility for existing
installations using this feature and Grafana does not have a
standardised way of migrating changes in the schema:
https://github.com/grafana/grafana/pull/9377#issuecomment-333063543

For reasons of expediency given the severity of the bug (not verifying
TLS), keep the old name.
Matt Bostock 8 years ago
parent
commit
4f3856adfb

+ 1 - 1
pkg/models/datasource_cache.go

@@ -48,7 +48,7 @@ func (ds *DataSource) GetHttpTransport() (*http.Transport, error) {
 
 
 	var tlsSkipVerify, tlsClientAuth, tlsAuthWithCACert bool
 	var tlsSkipVerify, tlsClientAuth, tlsAuthWithCACert bool
 	if ds.JsonData != nil {
 	if ds.JsonData != nil {
-		tlsClientAuth = ds.JsonData.Get("tlsClientAuth").MustBool(false)
+		tlsClientAuth = ds.JsonData.Get("tlsAuth").MustBool(false)
 		tlsAuthWithCACert = ds.JsonData.Get("tlsAuthWithCACert").MustBool(false)
 		tlsAuthWithCACert = ds.JsonData.Get("tlsAuthWithCACert").MustBool(false)
 		tlsSkipVerify = ds.JsonData.Get("tlsSkipVerify").MustBool(false)
 		tlsSkipVerify = ds.JsonData.Get("tlsSkipVerify").MustBool(false)
 	}
 	}

+ 1 - 1
pkg/models/datasource_cache_test.go

@@ -87,7 +87,7 @@ func TestDataSourceCache(t *testing.T) {
 		setting.SecretKey = "password"
 		setting.SecretKey = "password"
 
 
 		json := simplejson.New()
 		json := simplejson.New()
-		json.Set("tlsClientAuth", true)
+		json.Set("tlsAuth", true)
 
 
 		tlsClientCert, err := util.Encrypt([]byte(clientCert), "password")
 		tlsClientCert, err := util.Encrypt([]byte(clientCert), "password")
 		So(err, ShouldBeNil)
 		So(err, ShouldBeNil)

+ 3 - 3
public/app/features/plugins/partials/ds_http_settings.html

@@ -45,7 +45,7 @@
         <gf-form-switch class="gf-form" label="With Credentials" tooltip="Whether credentials such as cookies or auth headers should be sent with cross-site requests." checked="current.withCredentials" label-class="width-11" switch-class="max-width-6"></gf-form-switch>
         <gf-form-switch class="gf-form" label="With Credentials" tooltip="Whether credentials such as cookies or auth headers should be sent with cross-site requests." checked="current.withCredentials" label-class="width-11" switch-class="max-width-6"></gf-form-switch>
       </div>
       </div>
       <div class="gf-form-inline">
       <div class="gf-form-inline">
-        <gf-form-switch class="gf-form" ng-if="current.access=='proxy'" label="TLS Client Auth" label-class="width-8" checked="current.jsonData.tlsClientAuth" switch-class="max-width-6"></gf-form-switch>
+        <gf-form-switch class="gf-form" ng-if="current.access=='proxy'" label="TLS Client Auth" label-class="width-8" checked="current.jsonData.tlsAuth" switch-class="max-width-6"></gf-form-switch>
         <gf-form-switch class="gf-form" ng-if="current.access=='proxy'" label="With CA Cert" tooltip="Optional. Needed for self-signed TLS Certs." checked="current.jsonData.tlsAuthWithCACert" label-class="width-11" switch-class="max-width-6"></gf-form-switch>
         <gf-form-switch class="gf-form" ng-if="current.access=='proxy'" label="With CA Cert" tooltip="Optional. Needed for self-signed TLS Certs." checked="current.jsonData.tlsAuthWithCACert" label-class="width-11" switch-class="max-width-6"></gf-form-switch>
       </div>
       </div>
     </div>
     </div>
@@ -73,7 +73,7 @@
 	</div>
 	</div>
 </div>
 </div>
 
 
-<div class="gf-form-group" ng-if="(current.jsonData.tlsClientAuth || current.jsonData.tlsAuthWithCACert) && current.access=='proxy'">
+<div class="gf-form-group" ng-if="(current.jsonData.tlsAuth || current.jsonData.tlsAuthWithCACert) && current.access=='proxy'">
   <div class="gf-form">
   <div class="gf-form">
     <h6>TLS Auth Details</h6>
     <h6>TLS Auth Details</h6>
     <info-popover mode="header">TLS Certs are encrypted and stored in the Grafana database.</info-popover>
     <info-popover mode="header">TLS Certs are encrypted and stored in the Grafana database.</info-popover>
@@ -94,7 +94,7 @@
     </div>
     </div>
   </div>
   </div>
 
 
-  <div ng-if="current.jsonData.tlsClientAuth">
+  <div ng-if="current.jsonData.tlsAuth">
     <div class="gf-form-inline">
     <div class="gf-form-inline">
       <div class="gf-form gf-form--v-stretch">
       <div class="gf-form gf-form--v-stretch">
         <label class="gf-form-label width-7">Client Cert</label>
         <label class="gf-form-label width-7">Client Cert</label>