From daaa3e571bf7d7e4fb662a57506e7305442d3c21 Mon Sep 17 00:00:00 2001 From: Will Browne Date: Mon, 24 Aug 2020 16:49:45 +0200 Subject: [PATCH] Alerting: Store sensitive settings encrypted for Threema notifier (#27160) * encrypt API secret * update docs --- docs/sources/administration/provisioning.md | 10 +-- pkg/services/alerting/notifiers/threema.go | 92 +++++++++++---------- 2 files changed, 54 insertions(+), 48 deletions(-) diff --git a/docs/sources/administration/provisioning.md b/docs/sources/administration/provisioning.md index 2c30bca490f..61e15606a6d 100644 --- a/docs/sources/administration/provisioning.md +++ b/docs/sources/administration/provisioning.md @@ -528,11 +528,11 @@ The following sections detail the supported settings and secure settings for eac #### Alert notification `threema` -| Name | -| ------------ | -| gateway_id | -| recipient_id | -| api_secret | +| Name | Secure setting | +| ------------ | - | +| gateway_id | | +| recipient_id | | +| api_secret | yes | #### Alert notification `webhook` diff --git a/pkg/services/alerting/notifiers/threema.go b/pkg/services/alerting/notifiers/threema.go index 011ed8263ba..9a08fd67102 100644 --- a/pkg/services/alerting/notifiers/threema.go +++ b/pkg/services/alerting/notifiers/threema.go @@ -25,48 +25,54 @@ func init() { "The Threema Gateway ID can be set up at https://gateway.threema.ch/.", Factory: NewThreemaNotifier, OptionsTemplate: ` -

Threema Gateway settings

-

- Notifications can be configured for any Threema Gateway ID of type - "Basic". End-to-End IDs are not currently supported. -

-

- The Threema Gateway ID can be set up at - https://gateway.threema.ch/. -

-
- Gateway ID - - - - Your 8 character Threema Gateway ID (starting with a *) - -
-
- Recipient ID - - - - The 8 character Threema ID that should receive the alerts - -
-
- API Secret - - - - Your Threema Gateway API secret - -
- `, +

Threema Gateway settings

+

+ Notifications can be configured for any Threema Gateway ID of type + "Basic". End-to-End IDs are not currently supported. +

+

+ The Threema Gateway ID can be set up at + https://gateway.threema.ch/. +

+
+ Gateway ID + + + + Your 8 character Threema Gateway ID (starting with a *) + +
+
+ Recipient ID + + + + The 8 character Threema ID that should receive the alerts + +
+
+ +
+ + +
+
+ + reset +
+
+ `, Options: []alerting.NotifierOption{ { Label: "Gateway ID", @@ -118,7 +124,7 @@ func NewThreemaNotifier(model *models.AlertNotification) (alerting.Notifier, err gatewayID := model.Settings.Get("gateway_id").MustString() recipientID := model.Settings.Get("recipient_id").MustString() - apiSecret := model.Settings.Get("api_secret").MustString() + apiSecret := model.DecryptedValue("api_secret", model.Settings.Get("api_secret").MustString()) // Validation if gatewayID == "" {