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.
This commit is contained in:
Christian Segundo 2022-12-20 14:35:43 +01:00 committed by GitHub
parent ba6d2f2a82
commit 707198227c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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