Auth: Log a more useful msg if no OAuth provider configured (#56722)

Log a useful msg if no oauth provider configured

When a user doesn't configure an OAuth provider and uses auto login, Grafana logs a misleading message indicating that he has multiple providers configured.
pull/60581/head
Christian Segundo 3 years ago committed by GitHub
parent ba6d2f2a82
commit 707198227c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      pkg/api/login.go

@ -142,9 +142,12 @@ func (hs *HTTPServer) tryOAuthAutoLogin(c *models.ReqContext) bool {
return false
}
oauthInfos := hs.SocialService.GetOAuthInfoProviders()
if len(oauthInfos) != 1 {
if len(oauthInfos) > 1 {
c.Logger.Warn("Skipping OAuth auto login because multiple OAuth providers are configured")
return false
} else if len(oauthInfos) == 0 {
c.Logger.Warn("Skipping OAuth auto login because no OAuth providers are configured")
return false
}
for key := range oauthInfos {
redirectUrl := hs.Cfg.AppSubURL + "/login/" + key

Loading…
Cancel
Save