fix: clear all oauth Providers when reloading configuration (#5797)
* fix: clear all auth Providers when reloading configuration Signed-off-by: wenhaozhou <wenhaozhou@yunify.com> * fix:identity-provider test Signed-off-by: wenhaozhou <wenhaozhou@yunify.com> --------- Signed-off-by: wenhaozhou <wenhaozhou@yunify.com>
This commit is contained in:
@@ -47,6 +47,10 @@ type Identity interface {
|
||||
|
||||
// SetupWithOptions will verify the configuration and initialize the identityProviders
|
||||
func SetupWithOptions(options []oauth.IdentityProviderOptions) error {
|
||||
// Clear all providers when reloading configuration
|
||||
oauthProviders = make(map[string]OAuthProvider)
|
||||
genericProviders = make(map[string]GenericProvider)
|
||||
|
||||
for _, o := range options {
|
||||
if oauthProviders[o.Name] != nil || genericProviders[o.Name] != nil {
|
||||
err := fmt.Errorf("duplicate identity provider found: %s, name must be unique", o.Name)
|
||||
|
||||
@@ -113,6 +113,12 @@ func TestSetupWith(t *testing.T) {
|
||||
Type: "LDAPIdentityProvider",
|
||||
Provider: options.DynamicOptions{},
|
||||
},
|
||||
{
|
||||
Name: "ldap",
|
||||
MappingMethod: "auto",
|
||||
Type: "LDAPIdentityProvider",
|
||||
Provider: options.DynamicOptions{},
|
||||
},
|
||||
}},
|
||||
wantErr: true,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user