Auth: Fix SAML user IsExternallySynced not being set correctly (#98487)
This commit is contained in:
@@ -95,6 +95,10 @@ type SSOClientConfig interface {
|
||||
IsAutoLoginEnabled() bool
|
||||
// IsSingleLogoutEnabled returns true if the client has single logout enabled
|
||||
IsSingleLogoutEnabled() bool
|
||||
// IsSkipOrgRoleSyncEnabled returns true if the client has enabled skipping org role sync
|
||||
IsSkipOrgRoleSyncEnabled() bool
|
||||
// IsAllowAssignGrafanaAdminEnabled returns true if the client has enabled assigning grafana admin
|
||||
IsAllowAssignGrafanaAdminEnabled() bool
|
||||
}
|
||||
|
||||
type Service interface {
|
||||
|
||||
@@ -11,9 +11,11 @@ import (
|
||||
var _ authn.SSOClientConfig = new(FakeSSOClientConfig)
|
||||
|
||||
type FakeSSOClientConfig struct {
|
||||
ExpectedName string
|
||||
ExpectedIsAutoLoginEnabled bool
|
||||
ExpectedIsSingleLogoutEnabled bool
|
||||
ExpectedName string
|
||||
ExpectedIsAutoLoginEnabled bool
|
||||
ExpectedIsSingleLogoutEnabled bool
|
||||
ExpectedIsSkipOrgRoleSyncEnabled bool
|
||||
ExpectedIsAllowAssignGrafanaAdminEnabled bool
|
||||
}
|
||||
|
||||
func (f *FakeSSOClientConfig) GetDisplayName() string {
|
||||
@@ -28,6 +30,14 @@ func (f *FakeSSOClientConfig) IsSingleLogoutEnabled() bool {
|
||||
return f.ExpectedIsSingleLogoutEnabled
|
||||
}
|
||||
|
||||
func (f *FakeSSOClientConfig) IsSkipOrgRoleSyncEnabled() bool {
|
||||
return f.ExpectedIsSkipOrgRoleSyncEnabled
|
||||
}
|
||||
|
||||
func (f *FakeSSOClientConfig) IsAllowAssignGrafanaAdminEnabled() bool {
|
||||
return f.ExpectedIsAllowAssignGrafanaAdminEnabled
|
||||
}
|
||||
|
||||
var (
|
||||
_ authn.Service = new(FakeService)
|
||||
_ authn.IdentitySynchronizer = new(FakeService)
|
||||
@@ -41,6 +51,7 @@ type FakeService struct {
|
||||
ExpectedErrs []error
|
||||
ExpectedIdentities []*authn.Identity
|
||||
CurrentIndex int
|
||||
EnabledClients []string
|
||||
}
|
||||
|
||||
func (f *FakeService) Authenticate(ctx context.Context, r *authn.Request) (*authn.Identity, error) {
|
||||
@@ -64,7 +75,17 @@ func (f *FakeService) Authenticate(ctx context.Context, r *authn.Request) (*auth
|
||||
}
|
||||
|
||||
func (f *FakeService) IsClientEnabled(name string) bool {
|
||||
return true
|
||||
// Consider all clients as enabled if EnabledClients is not explicitly set
|
||||
if f.EnabledClients == nil {
|
||||
return true
|
||||
}
|
||||
// Check if client is in the list of enabled clients
|
||||
for _, s := range f.EnabledClients {
|
||||
if s == name {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (f *FakeService) GetClientConfig(name string) (authn.SSOClientConfig, bool) {
|
||||
|
||||
Reference in New Issue
Block a user