mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Store sensitive settings encrypted for Telegram notifier (#27122)
* encrypt bot token * update docs * re-add uploadImage to docs
This commit is contained in:
parent
e2c7ed4b82
commit
9feaa91bf5
@ -520,11 +520,11 @@ The following sections detail the supported settings and secure settings for eac
|
|||||||
|
|
||||||
#### Alert notification `telegram`
|
#### Alert notification `telegram`
|
||||||
|
|
||||||
| Name |
|
| Name | Secure setting |
|
||||||
| ----------- |
|
| ----------- | - |
|
||||||
| bottoken |
|
| bottoken | yes |
|
||||||
| chatid |
|
| chatid | |
|
||||||
| uploadImage |
|
| uploadImage | |
|
||||||
|
|
||||||
#### Alert notification `threema`
|
#### Alert notification `threema`
|
||||||
|
|
||||||
|
@ -30,23 +30,33 @@ func init() {
|
|||||||
Factory: NewTelegramNotifier,
|
Factory: NewTelegramNotifier,
|
||||||
OptionsTemplate: `
|
OptionsTemplate: `
|
||||||
<h3 class="page-heading">Telegram API settings</h3>
|
<h3 class="page-heading">Telegram API settings</h3>
|
||||||
<div class="gf-form">
|
<div class="gf-form max-width-30">
|
||||||
<span class="gf-form-label width-9">BOT API Token</span>
|
<label class="gf-form-label width-10">BOT API Token</label>
|
||||||
<input type="text" required
|
<div class="gf-form gf-form--grow" ng-if="!ctrl.model.secureFields.bottoken">
|
||||||
class="gf-form-input"
|
<input type="text"
|
||||||
ng-model="ctrl.model.settings.bottoken"
|
required
|
||||||
placeholder="Telegram BOT API Token"></input>
|
class="gf-form-input max-width-30"
|
||||||
</div>
|
ng-init="ctrl.model.secureSettings.bottoken = ctrl.model.settings.bottoken || null; ctrl.model.settings.bottoken = null;"
|
||||||
<div class="gf-form">
|
ng-model="ctrl.model.secureSettings.bottoken"
|
||||||
<span class="gf-form-label width-9">Chat ID</span>
|
placeholder="Telegram BOT API Token"
|
||||||
<input type="text" required
|
|
||||||
class="gf-form-input"
|
|
||||||
ng-model="ctrl.model.settings.chatid"
|
|
||||||
data-placement="right">
|
data-placement="right">
|
||||||
</input>
|
</input>
|
||||||
<info-popover mode="right-absolute">
|
</div>
|
||||||
Integer Telegram Chat Identifier
|
<div class="gf-form" ng-if="ctrl.model.secureFields.bottoken">
|
||||||
</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.bottoken = false">reset</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="gf-form max-width-30">
|
||||||
|
<label class="gf-form-label width-10">Chat ID</label>
|
||||||
|
<input type="text"
|
||||||
|
required
|
||||||
|
class="gf-form-input max-width-30"
|
||||||
|
ng-model="ctrl.model.settings.chatid"
|
||||||
|
placeholder="Telegram Chat ID"
|
||||||
|
data-placement="right">
|
||||||
|
</input>
|
||||||
|
<info-popover mode="right-absolute">Integer Telegram Chat Identifier</info-popover>
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
Options: []alerting.NotifierOption{
|
Options: []alerting.NotifierOption{
|
||||||
@ -86,7 +96,7 @@ func NewTelegramNotifier(model *models.AlertNotification) (alerting.Notifier, er
|
|||||||
return nil, alerting.ValidationError{Reason: "No Settings Supplied"}
|
return nil, alerting.ValidationError{Reason: "No Settings Supplied"}
|
||||||
}
|
}
|
||||||
|
|
||||||
botToken := model.Settings.Get("bottoken").MustString()
|
botToken := model.DecryptedValue("bottoken", model.Settings.Get("bottoken").MustString())
|
||||||
chatID := model.Settings.Get("chatid").MustString()
|
chatID := model.Settings.Get("chatid").MustString()
|
||||||
uploadImage := model.Settings.Get("uploadImage").MustBool()
|
uploadImage := model.Settings.Get("uploadImage").MustBool()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user