mirror of
https://github.com/grafana/grafana.git
synced 2025-01-04 13:17:16 -06:00
Get most recent oauth token from db, rather than lookup by auth_module
This commit is contained in:
parent
f17307bb97
commit
3b15e110a5
@ -220,15 +220,16 @@ func (proxy *DataSourceProxy) getDirector() func(req *http.Request) {
|
||||
}
|
||||
|
||||
if proxy.ds.JsonData != nil && proxy.ds.JsonData.Get("oauthPassThru").MustBool() {
|
||||
provider := proxy.ds.JsonData.Get("oauthPassThruProvider").MustString()
|
||||
cmd := &m.GetAuthInfoQuery{UserId: proxy.ctx.UserId}
|
||||
if err := bus.Dispatch(cmd); err != nil {
|
||||
logger.Error("Error feching oauth information for user", "error", err)
|
||||
}
|
||||
|
||||
provider := cmd.Result.AuthModule
|
||||
connect, ok := social.SocialMap[strings.TrimPrefix(provider, "oauth_")] // The socialMap keys don't have "oauth_" prefix, but everywhere else in the system does
|
||||
if !ok {
|
||||
logger.Error("Failed to find oauth provider with given name", "provider", provider)
|
||||
}
|
||||
cmd := &m.GetAuthInfoQuery{UserId: proxy.ctx.UserId, AuthModule: provider}
|
||||
if err := bus.Dispatch(cmd); err != nil {
|
||||
logger.Error("Error feching oauth information for user", "error", err)
|
||||
}
|
||||
|
||||
// TokenSource handles refreshing the token if it has expired
|
||||
token, err := connect.TokenSource(proxy.ctx.Req.Context(), &oauth2.Token{
|
||||
|
Loading…
Reference in New Issue
Block a user