Skip to content

Commit

Permalink
feat(saml): make getting providers from metadata non-panic (#1464)
Browse files Browse the repository at this point in the history
* feat(saml): make getting providers from metadata non-panic

* show a warning if a provider cannot be fetched by its metadata url
* skip the provider in provisioning state

Closes: #1445

* chore(provider): add provider name to error message

adds the idp config provider name to error message when
the provider host cannot be parsed from metadata url or
fetching metadata document fails.

Closes: #1445

---------

Co-authored-by: Stefan Jacobi <[email protected]>
  • Loading branch information
shentschel and Stefan Jacobi authored Jun 6, 2024
1 parent ef9ace6 commit d551f32
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions backend/ee/saml/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ func NewSamlHandler(cfg *config.Config, persister persistence.Persister, session
providers := make([]provider.ServiceProvider, 0)
for _, idpConfig := range cfg.Saml.IdentityProviders {
if idpConfig.Enabled {
name := ""
name, err := parseProviderFromMetadataUrl(idpConfig.MetadataUrl)
hostName := ""
hostName, err := parseProviderFromMetadataUrl(idpConfig.MetadataUrl)
if err != nil {
panic(err)
fmt.Printf("failed to parse provider '%s' from metadata url: %v\n", idpConfig.Name, err)
continue
}

newProvider, err := provider.GetProvider(name, cfg, idpConfig, persister.GetSamlCertificatePersister())
newProvider, err := provider.GetProvider(hostName, cfg, idpConfig, persister.GetSamlCertificatePersister())
if err != nil {
panic(err)
fmt.Printf("failed to initialize provider '%s': %v\n", idpConfig.Name, err)
continue
}

providers = append(providers, newProvider)
Expand Down

0 comments on commit d551f32

Please sign in to comment.