Commit ba8720e0 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

fix: irma server now shows error message when invalid requestor json is passed...

fix: irma server now shows error message when invalid requestor json is passed using flag or env var

Fixes #38
parent fa318049
...@@ -12,6 +12,7 @@ import ( ...@@ -12,6 +12,7 @@ import (
"github.com/privacybydesign/irmago/server" "github.com/privacybydesign/irmago/server"
"github.com/privacybydesign/irmago/server/requestorserver" "github.com/privacybydesign/irmago/server/requestorserver"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/spf13/cast"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
) )
...@@ -256,7 +257,10 @@ func configure(cmd *cobra.Command) error { ...@@ -256,7 +257,10 @@ func configure(cmd *cobra.Command) error {
} }
// Handle requestors // Handle requestors
requestors := viper.GetStringMap("requestors") requestors, err := cast.ToStringMapE(viper.Get("requestors"))
if err != nil {
return errors.WrapPrefix(err, "Failed to unmarshal requestors from flag or env var", 0)
}
if len(requestors) > 0 { if len(requestors) > 0 {
if err := mapstructure.Decode(requestors, &conf.Requestors); err != nil { if err := mapstructure.Decode(requestors, &conf.Requestors); err != nil {
return errors.WrapPrefix(err, "Failed to unmarshal requestors from config file", 0) return errors.WrapPrefix(err, "Failed to unmarshal requestors from config file", 0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment