From 3d21f06d5b21a323fc956844dd961aedf76e2951 Mon Sep 17 00:00:00 2001 From: bergquist Date: Thu, 24 Nov 2016 14:16:52 +0100 Subject: [PATCH] tech(cloudwatch): store keys in secure json blob --- pkg/api/cloudwatch/cloudwatch.go | 13 +++++++++++-- .../datasource/cloudwatch/partials/config.html | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/pkg/api/cloudwatch/cloudwatch.go b/pkg/api/cloudwatch/cloudwatch.go index c19df76f585..991d336411c 100644 --- a/pkg/api/cloudwatch/cloudwatch.go +++ b/pkg/api/cloudwatch/cloudwatch.go @@ -45,8 +45,17 @@ type datasourceInfo struct { func (req *cwRequest) GetDatasourceInfo() *datasourceInfo { assumeRoleArn := req.DataSource.JsonData.Get("assumeRoleArn").MustString() - accessKey := req.DataSource.JsonData.Get("accessKey").MustString() - secretKey := req.DataSource.JsonData.Get("secretKey").MustString() + accessKey := "" + secretKey := "" + + for key, value := range req.DataSource.SecureJsonData.Decrypt() { + if key == "accessKey" { + accessKey = value + } + if key == "secretKey" { + secretKey = value + } + } return &datasourceInfo{ AssumeRoleArn: assumeRoleArn, diff --git a/public/app/plugins/datasource/cloudwatch/partials/config.html b/public/app/plugins/datasource/cloudwatch/partials/config.html index c877ef470b0..9a5a4c68cf5 100644 --- a/public/app/plugins/datasource/cloudwatch/partials/config.html +++ b/public/app/plugins/datasource/cloudwatch/partials/config.html @@ -15,14 +15,14 @@
- + AWS Access key id
- + AWS Secret key