Alerting: Store sensitive settings encrypted for alertmanager notifier (#26318)

Ref #25967
This commit is contained in:
Mitsuhiro Tanda 2020-07-17 20:56:06 +09:00 committed by GitHub
parent 7969d6645a
commit 528a61b86b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,10 +33,21 @@ func init() {
<span class="gf-form-label width-10">Basic Auth User</span>
<input type="text" class="gf-form-input max-width-30" ng-model="ctrl.model.settings.basicAuthUser" placeholder=""></input>
</div>
<div class="gf-form max-width-30">
<span class="gf-form-label width-10">Basic Auth Password</span>
<input type="text" class="gf-form-input max-width-30" ng-model="ctrl.model.settings.basicAuthPassword" placeholder=""></input>
</div>
<div class="gf-form max-width-30">
<span class="gf-form-label width-10">Basic Auth Password</span>
<div class="gf-form gf-form--grow" ng-if="!ctrl.model.secureFields.basicAuthPassword">
<input type="text"
class="gf-form-input max-width-30"
ng-init="ctrl.model.secureSettings.basicAuthPassword = ctrl.model.settings.basicAuthPassword || null; ctrl.model.settings.basicAuthPassword = null;"
ng-model="ctrl.model.secureSettings.basicAuthPassword"
data-placement="right">
</input>
</div>
<div class="gf-form" ng-if="ctrl.model.secureFields.basicAuthPassword">
<input type="text" class="gf-form-input max-width-18" disabled="disabled" value="configured" />
<a class="btn btn-secondary gf-form-btn" href="#" ng-click="ctrl.model.secureFields.basicAuthPassword = false">reset</a>
</div>
</div>
</div>
`,
Options: []alerting.NotifierOption{
@ -80,7 +91,7 @@ func NewAlertmanagerNotifier(model *models.AlertNotification) (alerting.Notifier
}
}
basicAuthUser := model.Settings.Get("basicAuthUser").MustString()
basicAuthPassword := model.Settings.Get("basicAuthPassword").MustString()
basicAuthPassword := model.DecryptedValue("basicAuthPassword", model.Settings.Get("basicAuthPassword").MustString())
return &AlertmanagerNotifier{
NotifierBase: NewNotifierBase(model),