Commit daaa3e57 by Will Browne Committed by GitHub

Alerting: Store sensitive settings encrypted for Threema notifier (#27160)

* encrypt API secret

* update docs
parent 30d6405c
...@@ -528,11 +528,11 @@ The following sections detail the supported settings and secure settings for eac ...@@ -528,11 +528,11 @@ The following sections detail the supported settings and secure settings for eac
#### Alert notification `threema` #### Alert notification `threema`
| Name | | Name | Secure setting |
| ------------ | | ------------ | - |
| gateway_id | | gateway_id | |
| recipient_id | | recipient_id | |
| api_secret | | api_secret | yes |
#### Alert notification `webhook` #### Alert notification `webhook`
......
...@@ -34,37 +34,43 @@ func init() { ...@@ -34,37 +34,43 @@ func init() {
The Threema Gateway ID can be set up at The Threema Gateway ID can be set up at
<a href="https://gateway.threema.ch/" target="_blank" rel="noopener noreferrer">https://gateway.threema.ch/</a>. <a href="https://gateway.threema.ch/" target="_blank" rel="noopener noreferrer">https://gateway.threema.ch/</a>.
</p> </p>
<div class="gf-form"> <div class="gf-form max-width-30">
<span class="gf-form-label width-14">Gateway ID</span> <span class="gf-form-label width-8">Gateway ID</span>
<input type="text" required maxlength="8" pattern="\*[0-9A-Z]{7}" <input type="text" required maxlength="8" pattern="\*[0-9A-Z]{7}"
class="gf-form-input max-width-14" class="gf-form-input max-width-30"
ng-model="ctrl.model.settings.gateway_id" ng-model="ctrl.model.settings.gateway_id"
placeholder="*3MAGWID"> placeholder="*3MAGWID">
</input> </input>
<info-popover mode="right-normal"> <info-popover mode="right-absolute">
Your 8 character Threema Gateway ID (starting with a *) Your 8 character Threema Gateway ID (starting with a *)
</info-popover> </info-popover>
</div> </div>
<div class="gf-form"> <div class="gf-form max-width-30">
<span class="gf-form-label width-14">Recipient ID</span> <span class="gf-form-label width-8">Recipient ID</span>
<input type="text" required maxlength="8" pattern="[0-9A-Z]{8}" <input type="text" required maxlength="8" pattern="[0-9A-Z]{8}"
class="gf-form-input max-width-14" class="gf-form-input max-width-30"
ng-model="ctrl.model.settings.recipient_id" ng-model="ctrl.model.settings.recipient_id"
placeholder="YOUR3MID"> placeholder="YOUR3MID">
</input> </input>
<info-popover mode="right-normal"> <info-popover mode="right-absolute">
The 8 character Threema ID that should receive the alerts The 8 character Threema ID that should receive the alerts
</info-popover> </info-popover>
</div> </div>
<div class="gf-form"> <div class="gf-form max-width-30">
<span class="gf-form-label width-14">API Secret</span> <label class="gf-form-label width-8">API Secret</label>
<input type="text" required <div class="gf-form gf-form--grow" ng-if="!ctrl.model.secureFields.api_secret">
class="gf-form-input max-width-24" <input type="text"
ng-model="ctrl.model.settings.api_secret"> required
class="gf-form-input max-width-30"
ng-init="ctrl.model.secureSettings.api_secret = ctrl.model.settings.api_secret || null; ctrl.model.settings.api_secret = null;"
ng-model="ctrl.model.secureSettings.api_secret"
data-placement="right">
</input> </input>
<info-popover mode="right-normal"> </div>
Your Threema Gateway API secret <div class="gf-form" ng-if="ctrl.model.secureFields.api_secret">
</info-popover> <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.api_secret = false">reset</a>
</div>
</div> </div>
`, `,
Options: []alerting.NotifierOption{ Options: []alerting.NotifierOption{
...@@ -118,7 +124,7 @@ func NewThreemaNotifier(model *models.AlertNotification) (alerting.Notifier, err ...@@ -118,7 +124,7 @@ func NewThreemaNotifier(model *models.AlertNotification) (alerting.Notifier, err
gatewayID := model.Settings.Get("gateway_id").MustString() gatewayID := model.Settings.Get("gateway_id").MustString()
recipientID := model.Settings.Get("recipient_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 // Validation
if gatewayID == "" { if gatewayID == "" {
......
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