OAuth: Forward id token to the data source (#42422) (#42451)

* OAuth: Forward id token to the data source

* Add tests

* Forward id token in legacy API

* Check if id_token is string or not

(cherry picked from commit becfd776c3)
This commit is contained in:
Alexander Zobnin
2021-11-29 16:01:22 +01:00
committed by GitHub
parent cd17f65a05
commit 66ae92abe9
3 changed files with 24 additions and 6 deletions
+5
View File
@@ -230,6 +230,11 @@ func (hs *HTTPServer) createRequest(ctx context.Context, ds *models.DataSource,
if token := hs.OAuthTokenService.GetCurrentOAuthToken(ctx, query.User); token != nil {
delete(query.Headers, "Authorization")
query.Headers["Authorization"] = fmt.Sprintf("%s %s", token.Type(), token.AccessToken)
idToken, ok := token.Extra("id_token").(string)
if ok && idToken != "" {
query.Headers["X-ID-Token"] = idToken
}
}
}