Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
60617d0b
Commit
60617d0b
authored
Oct 08, 2018
by
Erik Sundell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stackdriver: wip - add logic for retrieving token from gce metadata server in the auth provider
parent
77e4c424
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
14 deletions
+15
-14
pkg/api/pluginproxy/ds_auth_provider.go
+12
-12
pkg/tsdb/stackdriver/stackdriver.go
+3
-2
No files found.
pkg/api/pluginproxy/ds_auth_provider.go
View file @
60617d0b
...
...
@@ -55,24 +55,24 @@ func ApplyRoute(ctx context.Context, req *http.Request, proxyPath string, route
}
}
// if route.JwtTokenAuth != nil && len(ds.SecureJsonData["privateKey"]) != 0 {
// if token, err := tokenProvider.getJwtAccessToken(ctx, data); err != nil {
// logger.Error("Failed to get access token", "error", err)
// } else {
// req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token))
// }
// }
if
ds
.
Type
==
"stackdriver"
{
defaultCredentials
,
err
:=
google
.
FindDefaultCredentials
(
ctx
,
route
.
JwtTokenAuth
.
Scopes
...
)
gceAutoAuthentication
:=
ds
.
JsonData
.
Get
(
"gceAutomaticAuthentication"
)
.
MustBool
()
if
route
.
JwtTokenAuth
!=
nil
&&
!
gceAutoAuthentication
{
if
token
,
err
:=
tokenProvider
.
getJwtAccessToken
(
ctx
,
data
);
err
!=
nil
{
logger
.
Error
(
"Failed to get access token"
,
"error"
,
err
)
}
else
{
req
.
Header
.
Add
(
"Authorization"
,
fmt
.
Sprintf
(
"Bearer %s"
,
token
))
}
}
if
gceAutoAuthentication
{
tokenSrc
,
err
:=
google
.
DefaultTokenSource
(
ctx
,
route
.
JwtTokenAuth
.
Scopes
...
)
if
err
!=
nil
{
logger
.
Error
(
"Failed to get default credentials"
,
"error"
,
err
)
}
else
{
token
,
err
:=
defaultCredentials
.
TokenSource
.
Token
()
token
,
err
:=
tokenSrc
.
Token
()
if
err
!=
nil
{
logger
.
Error
(
"Failed to get default access token"
,
"error"
,
err
)
}
else
{
ds
.
JsonData
.
Set
(
"defaultProject"
,
defaultCredentials
.
ProjectID
)
req
.
Header
.
Add
(
"Authorization"
,
fmt
.
Sprintf
(
"Bearer %s"
,
token
.
AccessToken
))
}
}
...
...
pkg/tsdb/stackdriver/stackdriver.go
View file @
60617d0b
...
...
@@ -521,8 +521,9 @@ func replaceWithMetricPart(metaPartName string, metricType string) []byte {
func
getProjectName
(
ctx
context
.
Context
,
dsInfo
*
models
.
DataSource
,
route
*
plugins
.
AppPluginRoute
)
(
string
,
error
)
{
var
projectName
string
gceAutoAuthentication
:=
dsInfo
.
JsonData
.
Get
(
"gceAutoAuthentication"
)
.
MustBool
()
if
gceAutoAuthentication
{
gceAutomaticAuthentication
:=
dsInfo
.
JsonData
.
Get
(
"gceAutomaticAuthentication"
)
.
MustBool
()
logger
.
Info
(
"gceAutomaticAuthentication"
,
"gceAutomaticAuthentication"
,
gceAutomaticAuthentication
)
if
gceAutomaticAuthentication
{
defaultCredentials
,
err
:=
google
.
FindDefaultCredentials
(
ctx
,
route
.
JwtTokenAuth
.
Scopes
...
)
if
err
!=
nil
{
return
""
,
err
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment