Fix /info endpoint 500 error when no openid providers were configured

This commit is contained in:
kolaente 2020-11-26 21:26:31 +01:00
parent ae6144c042
commit d2d610e0f5
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
2 changed files with 9 additions and 2 deletions

View file

@ -33,7 +33,12 @@ import (
func GetAllProviders() (providers []*Provider, err error) { func GetAllProviders() (providers []*Provider, err error) {
ps, err := keyvalue.Get("openid_providers") ps, err := keyvalue.Get("openid_providers")
if err != nil && kerr.IsErrValueNotFoundForKey(err) { 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 { for _, p := range rawProvider {
pi := p.(map[interface{}]interface{}) pi := p.(map[interface{}]interface{})

View file

@ -17,6 +17,7 @@
package v1 package v1
import ( import (
"code.vikunja.io/api/pkg/log"
"net/http" "net/http"
"code.vikunja.io/api/pkg/config" "code.vikunja.io/api/pkg/config"
@ -98,7 +99,8 @@ func Info(c echo.Context) error {
providers, err := openid.GetAllProviders() providers, err := openid.GetAllProviders()
if err != nil { 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 info.AuthInfo.OpenIDConnect.Providers = providers