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

* OAuth: Forward id token to the data source

* Add tests

* Forward id token in legacy API

* Check if id_token is string or not
This commit is contained in:
Alexander Zobnin
2021-11-29 15:40:05 +01:00
committed by GitHub
parent 58978dcf96
commit becfd776c3
3 changed files with 24 additions and 6 deletions
+5
View File
@@ -269,6 +269,11 @@ func (proxy *DataSourceProxy) director(req *http.Request) {
if proxy.oAuthTokenService.IsOAuthPassThruEnabled(proxy.ds) {
if token := proxy.oAuthTokenService.GetCurrentOAuthToken(proxy.ctx.Req.Context(), proxy.ctx.SignedInUser); token != nil {
req.Header.Set("Authorization", fmt.Sprintf("%s %s", token.Type(), token.AccessToken))
idToken, ok := token.Extra("id_token").(string)
if ok && idToken != "" {
req.Header.Set("X-ID-Token", idToken)
}
}
}
}