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:
Wenhao Zhou
2023-06-29 19:09:44 +08:00
committed by GitHub
parent d976069c5b
commit b1466e572b
2 changed files with 10 additions and 0 deletions

View File

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

View File

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