Commit 528a61b8 by Mitsuhiro Tanda Committed by GitHub

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

Ref #25967
parent 7969d664
...@@ -33,10 +33,21 @@ func init() { ...@@ -33,10 +33,21 @@ func init() {
<span class="gf-form-label width-10">Basic Auth User</span> <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> <input type="text" class="gf-form-input max-width-30" ng-model="ctrl.model.settings.basicAuthUser" placeholder=""></input>
</div> </div>
<div class="gf-form max-width-30"> <div class="gf-form max-width-30">
<span class="gf-form-label width-10">Basic Auth Password</span> <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 class="gf-form gf-form--grow" ng-if="!ctrl.model.secureFields.basicAuthPassword">
</div> <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> </div>
`, `,
Options: []alerting.NotifierOption{ Options: []alerting.NotifierOption{
...@@ -80,7 +91,7 @@ func NewAlertmanagerNotifier(model *models.AlertNotification) (alerting.Notifier ...@@ -80,7 +91,7 @@ func NewAlertmanagerNotifier(model *models.AlertNotification) (alerting.Notifier
} }
} }
basicAuthUser := model.Settings.Get("basicAuthUser").MustString() basicAuthUser := model.Settings.Get("basicAuthUser").MustString()
basicAuthPassword := model.Settings.Get("basicAuthPassword").MustString() basicAuthPassword := model.DecryptedValue("basicAuthPassword", model.Settings.Get("basicAuthPassword").MustString())
return &AlertmanagerNotifier{ return &AlertmanagerNotifier{
NotifierBase: NewNotifierBase(model), NotifierBase: NewNotifierBase(model),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment