[release-11.3.6] Auth: Introduce authn.SSOClientConfig to get client config from SSOSettings service (#103001)
Auth: Introduce authn.SSOClientConfig to get client config from SSOSettings service (#94618)
* wip
* possible solution
* Separate interface for SSO settings clients
* Rename interface
* Fix tests
* Rename
* Change GetClientConfig to comma ok idiom
(cherry picked from commit 50a635bc7e)
This commit is contained in:
+15
-3
@@ -359,15 +359,27 @@ func (hs *HTTPServer) samlEnabled() bool {
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) samlName() string {
|
||||
return hs.SettingsProvider.KeyValue("auth.saml", "name").MustString("SAML")
|
||||
config, ok := hs.authnService.GetClientConfig(authn.ClientSAML)
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
return config.GetDisplayName()
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) samlSingleLogoutEnabled() bool {
|
||||
return hs.samlEnabled() && hs.SettingsProvider.KeyValue("auth.saml", "single_logout").MustBool(false) && hs.samlEnabled()
|
||||
config, ok := hs.authnService.GetClientConfig(authn.ClientSAML)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
return hs.samlEnabled() && config.IsSingleLogoutEnabled()
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) samlAutoLoginEnabled() bool {
|
||||
return hs.samlEnabled() && hs.SettingsProvider.KeyValue("auth.saml", "auto_login").MustBool(false)
|
||||
config, ok := hs.authnService.GetClientConfig(authn.ClientSAML)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
return hs.samlEnabled() && config.IsAutoLoginEnabled()
|
||||
}
|
||||
|
||||
func getLoginExternalError(err error) string {
|
||||
|
||||
@@ -659,7 +659,11 @@ func TestLogoutSaml(t *testing.T) {
|
||||
license.On("FeatureEnabled", "saml").Return(true)
|
||||
|
||||
hs := &HTTPServer{
|
||||
authnService: &authntest.FakeService{},
|
||||
authnService: &authntest.FakeService{
|
||||
ExpectedClientConfig: &authntest.FakeSSOClientConfig{
|
||||
ExpectedIsSingleLogoutEnabled: true,
|
||||
},
|
||||
},
|
||||
Cfg: sc.cfg,
|
||||
SettingsProvider: &setting.OSSImpl{Cfg: sc.cfg},
|
||||
License: license,
|
||||
|
||||
Reference in New Issue
Block a user