From d2d610e0f5f0d8618145d4d83d4fd37bc49072ba Mon Sep 17 00:00:00 2001 From: kolaente Date: Thu, 26 Nov 2020 21:26:31 +0100 Subject: [PATCH] Fix /info endpoint 500 error when no openid providers were configured --- pkg/modules/auth/openid/providers.go | 7 ++++++- pkg/routes/api/v1/info.go | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/modules/auth/openid/providers.go b/pkg/modules/auth/openid/providers.go index 7d4133ba..5f23d3da 100644 --- a/pkg/modules/auth/openid/providers.go +++ b/pkg/modules/auth/openid/providers.go @@ -33,7 +33,12 @@ import ( func GetAllProviders() (providers []*Provider, err error) { ps, err := keyvalue.Get("openid_providers") if err != nil && kerr.IsErrValueNotFoundForKey(err) { - rawProvider := config.AuthOpenIDProviders.Get().([]interface{}) + rawProviders := config.AuthOpenIDProviders.Get() + if rawProviders == nil { + return nil, nil + } + + rawProvider := rawProviders.([]interface{}) for _, p := range rawProvider { pi := p.(map[interface{}]interface{}) diff --git a/pkg/routes/api/v1/info.go b/pkg/routes/api/v1/info.go index faa06db5..63dd40d4 100644 --- a/pkg/routes/api/v1/info.go +++ b/pkg/routes/api/v1/info.go @@ -17,6 +17,7 @@ package v1 import ( + "code.vikunja.io/api/pkg/log" "net/http" "code.vikunja.io/api/pkg/config" @@ -98,7 +99,8 @@ func Info(c echo.Context) error { providers, err := openid.GetAllProviders() if err != nil { - return err + log.Errorf("Error while getting openid providers for /info: %s", err) + // No return here to not break /info } info.AuthInfo.OpenIDConnect.Providers = providers