mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Auth: Always include oauth and saml settings for frontend (#58705)
* Auth: Always include oauth and saml settings
This commit is contained in:
parent
d999b5bda0
commit
98dbc637cc
@ -198,6 +198,9 @@ func (hs *HTTPServer) getFrontendSettingsMap(c *models.ReqContext) (map[string]i
|
|||||||
"unifiedAlerting": map[string]interface{}{
|
"unifiedAlerting": map[string]interface{}{
|
||||||
"minInterval": hs.Cfg.UnifiedAlerting.MinInterval.String(),
|
"minInterval": hs.Cfg.UnifiedAlerting.MinInterval.String(),
|
||||||
},
|
},
|
||||||
|
"oauth": hs.getEnabledOAuthProviders(),
|
||||||
|
"samlEnabled": hs.samlEnabled(),
|
||||||
|
"samlName": hs.samlName(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if hs.ThumbService != nil {
|
if hs.ThumbService != nil {
|
||||||
@ -501,3 +504,14 @@ func (hs *HTTPServer) pluginSettings(ctx context.Context, orgID int64) (map[stri
|
|||||||
|
|
||||||
return pluginSettings, nil
|
return pluginSettings, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (hs *HTTPServer) getEnabledOAuthProviders() map[string]interface{} {
|
||||||
|
providers := make(map[string]interface{})
|
||||||
|
for key, oauth := range hs.SocialService.GetOAuthInfoProviders() {
|
||||||
|
providers[key] = map[string]string{
|
||||||
|
"name": oauth.Name,
|
||||||
|
"icon": oauth.Icon,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return providers
|
||||||
|
}
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/grafana/grafana/pkg/login/social"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
@ -57,6 +58,7 @@ func setupTestEnvironment(t *testing.T, cfg *setting.Cfg, features *featuremgmt.
|
|||||||
grafanaUpdateChecker: &updatechecker.GrafanaService{},
|
grafanaUpdateChecker: &updatechecker.GrafanaService{},
|
||||||
AccessControl: accesscontrolmock.New().WithDisabled(),
|
AccessControl: accesscontrolmock.New().WithDisabled(),
|
||||||
PluginSettings: pluginSettings.ProvideService(sqlStore, secretsService),
|
PluginSettings: pluginSettings.ProvideService(sqlStore, secretsService),
|
||||||
|
SocialService: social.ProvideService(cfg),
|
||||||
}
|
}
|
||||||
|
|
||||||
m := web.New()
|
m := web.New()
|
||||||
|
@ -91,19 +91,6 @@ func (hs *HTTPServer) LoginView(c *models.ReqContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
enabledOAuths := make(map[string]interface{})
|
|
||||||
providers := hs.SocialService.GetOAuthInfoProviders()
|
|
||||||
for key, oauth := range providers {
|
|
||||||
enabledOAuths[key] = map[string]string{
|
|
||||||
"name": oauth.Name,
|
|
||||||
"icon": oauth.Icon,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
viewData.Settings["oauth"] = enabledOAuths
|
|
||||||
viewData.Settings["samlEnabled"] = hs.samlEnabled()
|
|
||||||
viewData.Settings["samlName"] = hs.samlName()
|
|
||||||
|
|
||||||
if loginError, ok := hs.tryGetEncryptedCookie(c, loginErrorCookieName); ok {
|
if loginError, ok := hs.tryGetEncryptedCookie(c, loginErrorCookieName); ok {
|
||||||
// this cookie is only set whenever an OAuth login fails
|
// this cookie is only set whenever an OAuth login fails
|
||||||
// therefore the loginError should be passed to the view data
|
// therefore the loginError should be passed to the view data
|
||||||
|
Loading…
Reference in New Issue
Block a user