Skip to content

Commit

Permalink
refactor: removes need to add provider to list of supported providers…
Browse files Browse the repository at this point in the history
… in error message
  • Loading branch information
NickUfer committed Oct 14, 2020
1 parent 7f840b5 commit cb0aed9
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions selfservice/strategy/oidc/provider_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,18 @@ func (c ConfigurationCollection) Provider(id string, public *url.URL) (Provider,
for k := range c.Providers {
p := c.Providers[k]
if p.ID == id {
switch p.Provider {
case "generic":
return NewProviderGenericOIDC(&p, public), nil
case "google":
return NewProviderGoogle(&p, public), nil
case "github":
return NewProviderGitHub(&p, public), nil
case "gitlab":
return NewProviderGitLab(&p, public), nil
case "microsoft":
return NewProviderMicrosoft(&p, public), nil
for providerName, provider := range providers {
if providerName == p.Provider {
return provider(&p), nil
}
}
return nil, errors.Errorf("provider type %s is not supported, supported are: %v", p.Provider, []string{"generic", "google", "github", "gitlab", "microsoft"})
providerNames := make([]string, len(providers))
i := 0
for provider := range providers {
providerNames[i] = provider
i++
}
return nil, errors.Errorf("provider type %s is not supported, supported are: %v", p.Provider, providerNames)
}
}
return nil, errors.WithStack(herodot.ErrNotFound.WithReasonf(`OpenID Connect Provider "%s" is unknown or has not been configured`, id))
Expand Down

0 comments on commit cb0aed9

Please sign in to comment.