Commit 3f9ed2ef by Erik Sundell

stackdriver: wip - temp remove jwt token auth

parent b2de0d8c
...@@ -64,11 +64,7 @@ func ApplyRoute(ctx context.Context, req *http.Request, proxyPath string, route ...@@ -64,11 +64,7 @@ func ApplyRoute(ctx context.Context, req *http.Request, proxyPath string, route
// } // }
if ds.Type == "stackdriver" { if ds.Type == "stackdriver" {
defaultCredentials, err := google.FindDefaultCredentials(ctx, "https://www.googleapis.com/auth/monitoring.read") defaultCredentials, err := google.FindDefaultCredentials(ctx, route.JwtTokenAuth.Scopes...)
projectName := ds.JsonData.Get("defaultProject").MustString()
if projectName == "" {
ds.JsonData.Set("defaultProject", defaultCredentials.ProjectID)
}
if err != nil { if err != nil {
logger.Error("Failed to get default credentials", "error", err) logger.Error("Failed to get default credentials", "error", err)
} else { } else {
...@@ -76,6 +72,7 @@ func ApplyRoute(ctx context.Context, req *http.Request, proxyPath string, route ...@@ -76,6 +72,7 @@ func ApplyRoute(ctx context.Context, req *http.Request, proxyPath string, route
if err != nil { if err != nil {
logger.Error("Failed to get default access token", "error", err) logger.Error("Failed to get default access token", "error", err)
} else { } else {
ds.JsonData.Set("defaultProject", defaultCredentials.ProjectID)
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token.AccessToken)) req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token.AccessToken))
} }
} }
......
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