Commit 9f2386a2 by Will Browne Committed by GitHub

Alerting: Store sensitive settings encrypted for OpsGenie notifier (#27074)

* encrypt OpsGenie API key

* make whitespace consistent

* update docs
parent 6b2d4441
......@@ -511,12 +511,12 @@ The following sections detail the supported settings and secure settings for eac
#### Alert notification `opsgenie`
| Name |
| ---------------- |
| apiKey |
| apiUrl |
| autoClose |
| overridePriority |
| Name | Secure setting |
| ---------------- | - |
| apiKey | yes |
| apiUrl | |
| autoClose | |
| overridePriority | |
#### Alert notification `telegram`
......
......@@ -19,33 +19,46 @@ func init() {
Heading: "OpsGenie settings",
Factory: NewOpsGenieNotifier,
OptionsTemplate: `
<h3 class="page-heading">OpsGenie settings</h3>
<div class="gf-form">
<span class="gf-form-label width-14">API Key</span>
<input type="text" required class="gf-form-input max-width-22" ng-model="ctrl.model.settings.apiKey" placeholder="OpsGenie API Key"></input>
</div>
<div class="gf-form">
<span class="gf-form-label width-14">Alert API Url</span>
<input type="text" required class="gf-form-input max-width-22" ng-model="ctrl.model.settings.apiUrl" placeholder="https://api.opsgenie.com/v2/alerts"></input>
</div>
<div class="gf-form">
<gf-form-switch
class="gf-form"
label="Auto close incidents"
label-class="width-14"
checked="ctrl.model.settings.autoClose"
tooltip="Automatically close alerts in OpsGenie once the alert goes back to ok.">
</gf-form-switch>
</div>
<div class="gf-form">
<gf-form-switch
class="gf-form"
label="Override priority"
label-class="width-14"
checked="ctrl.model.settings.overridePriority"
tooltip="Allow the alert priority to be set using the og_priority tag">
</gf-form-switch>
</div>
<h3 class="page-heading">OpsGenie settings</h3>
<div class="gf-form">
<label class="gf-form-label max-width-14">API Key</label>
<div class="gf-form gf-form--grow" ng-if="!ctrl.model.secureFields.apiKey">
<input type="text"
required
class="gf-form-input max-width-22"
ng-init="ctrl.model.secureSettings.apiKey = ctrl.model.settings.apiKey || null; ctrl.model.settings.apiKey = null;"
ng-model="ctrl.model.secureSettings.apiKey"
placeholder="OpsGenie API Key"
data-placement="right">
</input>
</div>
<div class="gf-form" ng-if="ctrl.model.secureFields.apiKey">
<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.apiKey = false">reset</a>
</div>
</div>
<div class="gf-form">
<span class="gf-form-label width-14">Alert API Url</span>
<input type="text" required class="gf-form-input max-width-22" ng-model="ctrl.model.settings.apiUrl" placeholder="https://api.opsgenie.com/v2/alerts"></input>
</div>
<div class="gf-form">
<gf-form-switch
class="gf-form"
label="Auto close incidents"
label-class="width-14"
checked="ctrl.model.settings.autoClose"
tooltip="Automatically close alerts in OpsGenie once the alert goes back to ok.">
</gf-form-switch>
</div>
<div class="gf-form">
<gf-form-switch
class="gf-form"
label="Override priority"
label-class="width-14"
checked="ctrl.model.settings.overridePriority"
tooltip="Allow the alert priority to be set using the og_priority tag">
</gf-form-switch>
</div>
`,
Options: []alerting.NotifierOption{
{
......@@ -87,7 +100,7 @@ var (
func NewOpsGenieNotifier(model *models.AlertNotification) (alerting.Notifier, error) {
autoClose := model.Settings.Get("autoClose").MustBool(true)
overridePriority := model.Settings.Get("overridePriority").MustBool(true)
apiKey := model.Settings.Get("apiKey").MustString()
apiKey := model.DecryptedValue("apiKey", model.Settings.Get("apiKey").MustString())
apiURL := model.Settings.Get("apiUrl").MustString()
if apiKey == "" {
return nil, alerting.ValidationError{Reason: "Could not find api key property in settings"}
......
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