mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
This commit is contained in:
@@ -206,17 +206,12 @@ func convertModelToDtos(ds *m.DataSource) dtos.DataSource {
|
|||||||
WithCredentials: ds.WithCredentials,
|
WithCredentials: ds.WithCredentials,
|
||||||
IsDefault: ds.IsDefault,
|
IsDefault: ds.IsDefault,
|
||||||
JsonData: ds.JsonData,
|
JsonData: ds.JsonData,
|
||||||
}
|
SecureJsonFields: map[string]bool{},
|
||||||
|
|
||||||
if len(ds.SecureJsonData) > 0 {
|
|
||||||
dto.TLSAuth.CACertSet = len(ds.SecureJsonData["tlsCACert"]) > 0
|
|
||||||
dto.TLSAuth.ClientCertSet = len(ds.SecureJsonData["tlsClientCert"]) > 0
|
|
||||||
dto.TLSAuth.ClientKeySet = len(ds.SecureJsonData["tlsClientKey"]) > 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, v := range ds.SecureJsonData {
|
for k, v := range ds.SecureJsonData {
|
||||||
if len(v) > 0 {
|
if len(v) > 0 {
|
||||||
dto.EncryptedFields = append(dto.EncryptedFields, k)
|
dto.SecureJsonFields[k] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,15 +81,7 @@ type DataSource struct {
|
|||||||
WithCredentials bool `json:"withCredentials"`
|
WithCredentials bool `json:"withCredentials"`
|
||||||
IsDefault bool `json:"isDefault"`
|
IsDefault bool `json:"isDefault"`
|
||||||
JsonData *simplejson.Json `json:"jsonData,omitempty"`
|
JsonData *simplejson.Json `json:"jsonData,omitempty"`
|
||||||
TLSAuth TLSAuth `json:"tlsAuth,omitempty"`
|
SecureJsonFields map[string]bool `json:"secureJsonFields"`
|
||||||
EncryptedFields []string `json:"encryptedFields"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// TLSAuth is used to show if TLS certs have been uploaded already
|
|
||||||
type TLSAuth struct {
|
|
||||||
CACertSet bool `json:"tlsCACertSet"`
|
|
||||||
ClientCertSet bool `json:"tlsClientCertSet"`
|
|
||||||
ClientKeySet bool `json:"tlsClientKeySet"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type DataSourceList []DataSource
|
type DataSourceList []DataSource
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ var defaults = {
|
|||||||
url: '',
|
url: '',
|
||||||
access: 'proxy',
|
access: 'proxy',
|
||||||
jsonData: {},
|
jsonData: {},
|
||||||
encryptedFields: []
|
secureJsonFields: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
var datasourceCreated = false;
|
var datasourceCreated = false;
|
||||||
|
|||||||
@@ -89,13 +89,13 @@
|
|||||||
<div class="gf-form gf-form--v-stretch">
|
<div class="gf-form gf-form--v-stretch">
|
||||||
<label class="gf-form-label width-7">CA Cert</label>
|
<label class="gf-form-label width-7">CA Cert</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="gf-form gf-form--grow" ng-if="!current.tlsAuth.tlsCACertSet">
|
<div class="gf-form gf-form--grow" ng-if="!current.secureJsonFields.tlsCACert">
|
||||||
<textarea rows="7" class="gf-form-input gf-form-textarea" ng-model="current.secureJsonData.tlsCACert" placeholder="Begins with -----BEGIN CERTIFICATE-----. The CA Certificate is necessary if you are using self-signed certificates."></textarea>
|
<textarea rows="7" class="gf-form-input gf-form-textarea" ng-model="current.secureJsonData.tlsCACert" placeholder="Begins with -----BEGIN CERTIFICATE-----. The CA Certificate is necessary if you are using self-signed certificates."></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="gf-form" ng-if="current.tlsAuth.tlsCACertSet">
|
<div class="gf-form" ng-if="current.secureJsonFields.tlsCACert">
|
||||||
<input type="text" class="gf-form-input max-width-12" disabled="disabled" value="configured">
|
<input type="text" class="gf-form-input max-width-12" disabled="disabled" value="configured">
|
||||||
<a class="btn btn-secondary gf-form-btn" href="#" ng-if="current.tlsAuth.tlsCACertSet" ng-click="current.tlsAuth.tlsCACertSet = false">reset</a>
|
<a class="btn btn-secondary gf-form-btn" href="#" ng-click="current.secureJsonFields.tlsCACert = false">reset</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -104,12 +104,12 @@
|
|||||||
<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>
|
||||||
</div>
|
</div>
|
||||||
<div class="gf-form gf-form--grow" ng-if="!current.tlsAuth.tlsClientCertSet">
|
<div class="gf-form gf-form--grow" ng-if="!current.secureJsonFields.tlsClientCert">
|
||||||
<textarea rows="7" class="gf-form-input gf-form-textarea" ng-model="current.secureJsonData.tlsClientCert" placeholder="Begins with -----BEGIN CERTIFICATE-----" required></textarea>
|
<textarea rows="7" class="gf-form-input gf-form-textarea" ng-model="current.secureJsonData.tlsClientCert" placeholder="Begins with -----BEGIN CERTIFICATE-----" required></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="gf-form" ng-if="current.tlsAuth.tlsClientCertSet">
|
<div class="gf-form" ng-if="current.secureJsonFields.tlsClientCert">
|
||||||
<input type="text" class="gf-form-input max-width-12" disabled="disabled" value="configured">
|
<input type="text" class="gf-form-input max-width-12" disabled="disabled" value="configured">
|
||||||
<a class="btn btn-secondary gf-form-btn" href="#" ng-if="current.tlsAuth.tlsClientCertSet" ng-click="current.tlsAuth.tlsClientCertSet = false">reset</a>
|
<a class="btn btn-secondary gf-form-btn" href="#" ng-click="current.secureJsonFields.tlsClientCert = false">reset</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -117,12 +117,12 @@
|
|||||||
<div class="gf-form gf-form--v-stretch">
|
<div class="gf-form gf-form--v-stretch">
|
||||||
<label class="gf-form-label width-7">Client Key</label>
|
<label class="gf-form-label width-7">Client Key</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="gf-form gf-form--grow" ng-if="!current.tlsAuth.tlsClientKeySet">
|
<div class="gf-form gf-form--grow" ng-if="!current.secureJsonFields.tlsClientKey">
|
||||||
<textarea rows="7" class="gf-form-input gf-form-textarea" ng-model="current.secureJsonData.tlsClientKey" placeholder="Begins with -----BEGIN RSA PRIVATE KEY-----" required></textarea>
|
<textarea rows="7" class="gf-form-input gf-form-textarea" ng-model="current.secureJsonData.tlsClientKey" placeholder="Begins with -----BEGIN RSA PRIVATE KEY-----" required></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="gf-form" ng-if="current.tlsAuth.tlsClientKeySet">
|
<div class="gf-form" ng-if="current.secureJsonFields.tlsClientKey">
|
||||||
<input type="text" class="gf-form-input max-width-12" disabled="disabled" value="configured">
|
<input type="text" class="gf-form-input max-width-12" disabled="disabled" value="configured">
|
||||||
<a class="btn btn-secondary gf-form-btn" href="#" ng-if="current.tlsAuth.tlsClientKeySet" ng-click="current.tlsAuth.tlsClientKeySet = false">reset</a>
|
<a class="btn btn-secondary gf-form-btn" href="#" ng-click="current.secureJsonFields.tlsClientKey = false">reset</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -15,14 +15,8 @@ export class CloudWatchConfigCtrl {
|
|||||||
this.current.jsonData.timeField = this.current.jsonData.timeField || '@timestamp';
|
this.current.jsonData.timeField = this.current.jsonData.timeField || '@timestamp';
|
||||||
this.current.jsonData.authType = this.current.jsonData.authType || 'credentials';
|
this.current.jsonData.authType = this.current.jsonData.authType || 'credentials';
|
||||||
|
|
||||||
for (let key of this.current.encryptedFields) {
|
this.accessKeyExist = this.current.secureJsonFields.accessKey;
|
||||||
if (key === "accessKey") {
|
this.secretKeyExist = this.current.secureJsonFields.secretKey;
|
||||||
this.accessKeyExist = true;
|
|
||||||
}
|
|
||||||
if (key === "secretKey") {
|
|
||||||
this.secretKeyExist = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resetAccessKey() {
|
resetAccessKey() {
|
||||||
|
|||||||
Reference in New Issue
Block a user