Commit 2b1709b8 by Erik Sundell

stackdriver: only get default token from metadata server when applying route

parent dd9e9ed4
...@@ -12,6 +12,7 @@ import ( ...@@ -12,6 +12,7 @@ import (
m "github.com/grafana/grafana/pkg/models" m "github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/plugins" "github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/util" "github.com/grafana/grafana/pkg/util"
"golang.org/x/oauth2/google"
) )
//ApplyRoute should use the plugin route data to set auth headers and custom headers //ApplyRoute should use the plugin route data to set auth headers and custom headers
...@@ -64,18 +65,16 @@ func ApplyRoute(ctx context.Context, req *http.Request, proxyPath string, route ...@@ -64,18 +65,16 @@ func ApplyRoute(ctx context.Context, req *http.Request, proxyPath string, route
} }
} }
if gceAutoAuthentication { if gceAutoAuthentication && route.JwtTokenAuth == nil {
// tokenSrc, err := google.DefaultTokenSource(ctx, route.JwtTokenAuth.Scopes...) tokenSrc, err := google.DefaultTokenSource(ctx, route.JwtTokenAuth.Scopes...)
if err != nil { if err != nil {
logger.Error("Failed to get default credentials", "error", err) logger.Error("Failed to get default token from meta data server", "error", err)
} else { } else {
// token, err := tokenSrc.Token() token, err := tokenSrc.Token()
token, err := tokenProvider.getJwtAccessToken(ctx, data)
if err != nil { if err != nil {
logger.Error("Failed to get default access token", "error", err) logger.Error("Failed to get default access token from meta data server", "error", err)
} else { } else {
// req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token.AccessToken)) req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token.AccessToken))
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token))
} }
} }
} }
......
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