Commit 30d6405c by Will Browne Committed by GitHub

Alerting: Store sensitive settings encrypted for Pushover notifier (#27159)

* encrypt api + user keys

* update docs

* fix decrypt steps
parent bbbbf9ac
...@@ -414,13 +414,13 @@ The following sections detail the supported settings and secure settings for eac ...@@ -414,13 +414,13 @@ The following sections detail the supported settings and secure settings for eac
#### Alert notification `pushover` #### Alert notification `pushover`
| Name | | Name | Secure setting |
| -------- | | -------- | -------------- |
| apiToken | | apiToken | yes |
| userKey | | userKey | yes |
| device | | device | |
| retry | | retry | |
| expire | | expire | |
#### Alert notification `slack` #### Alert notification `slack`
......
...@@ -123,15 +123,40 @@ func init() { ...@@ -123,15 +123,40 @@ func init() {
Heading: "Pushover settings", Heading: "Pushover settings",
Factory: NewPushoverNotifier, Factory: NewPushoverNotifier,
OptionsTemplate: ` OptionsTemplate: `
<h3 class="page-heading">Pushover settings</h3> <h3 class="page-heading">Pushover settings</h3>
<div class="gf-form"> <div class="gf-form">
<span class="gf-form-label width-10">API Token</span> <label class="gf-form-label width-10">API Token</label>
<input type="text" class="gf-form-input" required placeholder="Application token" ng-model="ctrl.model.settings.apiToken"></input> <div class="gf-form gf-form--grow" ng-if="!ctrl.model.secureFields.apiToken">
</div> <input type="text"
<div class="gf-form"> required
<span class="gf-form-label width-10">User key(s)</span> class="gf-form-input"
<input type="text" class="gf-form-input" required placeholder="comma-separated list" ng-model="ctrl.model.settings.userKey"></input> ng-init="ctrl.model.secureSettings.apiToken = ctrl.model.settings.apiToken || null; ctrl.model.settings.apiToken = null;"
</div> ng-model="ctrl.model.secureSettings.apiToken"
data-placement="right">
</input>
</div>
<div class="gf-form" ng-if="ctrl.model.secureFields.apiToken">
<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.apiToken = false">reset</a>
</div>
</div>
<div class="gf-form">
<label class="gf-form-label max-width-10">User Key(s)</label>
<div class="gf-form gf-form--grow" ng-if="!ctrl.model.secureFields.userKey">
<input type="text"
required
class="gf-form-input"
ng-init="ctrl.model.secureSettings.userKey = ctrl.model.settings.userKey || null; ctrl.model.settings.userKey = null;"
ng-model="ctrl.model.secureSettings.userKey"
placeholder="comma-separated list"
data-placement="right">
</input>
</div>
<div class="gf-form" ng-if="ctrl.model.secureFields.userKey">
<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.userKey = false">reset</a>
</div>
</div>
<div class="gf-form"> <div class="gf-form">
<span class="gf-form-label width-10">Device(s) (optional)</span> <span class="gf-form-label width-10">Device(s) (optional)</span>
<input type="text" class="gf-form-input" placeholder="comma-separated list; leave empty to send to all devices" ng-model="ctrl.model.settings.device"></input> <input type="text" class="gf-form-input" placeholder="comma-separated list; leave empty to send to all devices" ng-model="ctrl.model.settings.device"></input>
...@@ -258,8 +283,8 @@ func init() { ...@@ -258,8 +283,8 @@ func init() {
// NewPushoverNotifier is the constructor for the Pushover Notifier // NewPushoverNotifier is the constructor for the Pushover Notifier
func NewPushoverNotifier(model *models.AlertNotification) (alerting.Notifier, error) { func NewPushoverNotifier(model *models.AlertNotification) (alerting.Notifier, error) {
userKey := model.Settings.Get("userKey").MustString() userKey := model.DecryptedValue("userKey", model.Settings.Get("userKey").MustString())
APIToken := model.Settings.Get("apiToken").MustString() APIToken := model.DecryptedValue("apiToken", model.Settings.Get("apiToken").MustString())
device := model.Settings.Get("device").MustString() device := model.Settings.Get("device").MustString()
priority, _ := strconv.Atoi(model.Settings.Get("priority").MustString()) priority, _ := strconv.Atoi(model.Settings.Get("priority").MustString())
retry, _ := strconv.Atoi(model.Settings.Get("retry").MustString()) retry, _ := strconv.Atoi(model.Settings.Get("retry").MustString())
......
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