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

feat: enforce that keyshare and myirma servers use postgres db type in production

parent 9adf36df
package cmd
import (
"github.com/go-errors/errors"
irma "github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/server"
"github.com/privacybydesign/irmago/server/keyshare/myirmaserver"
......@@ -12,7 +13,10 @@ var myirmaServerCmd = &cobra.Command{
Use: "myirmaserver",
Short: "IRMA keyshare MyIRMA server",
Run: func(command *cobra.Command, args []string) {
conf := configureMyirmaServer(command)
conf, err := configureMyirmaServer(command)
if err != nil {
die("failed to read configuration", err)
}
// Create main server
myirmaServer, err := myirmaserver.New(conf)
......@@ -83,7 +87,7 @@ func init() {
flags.Lookup("verbose").Header = `Other options`
}
func configureMyirmaServer(cmd *cobra.Command) *myirmaserver.Configuration {
func configureMyirmaServer(cmd *cobra.Command) (*myirmaserver.Configuration, error) {
readConfig(cmd, "myirmaserver", "myirmaserver", []string{".", "/etc/myirmaserver/"}, nil)
// And build the configuration
......@@ -111,6 +115,10 @@ func configureMyirmaServer(cmd *cobra.Command) *myirmaserver.Configuration {
SessionLifetime: viper.GetInt("session-lifetime"),
}
if conf.Production && conf.DBType != myirmaserver.DBTypePostgres {
return nil, errors.New("in production mode, db-type must be postgres")
}
conf.URL = server.ReplacePortString(viper.GetString("url"), viper.GetInt("port"))
for _, v := range viper.GetStringSlice("keyshare-attributes") {
......@@ -124,5 +132,5 @@ func configureMyirmaServer(cmd *cobra.Command) *myirmaserver.Configuration {
irma.NewAttributeTypeIdentifier(v))
}
return conf
return conf, nil
}
package cmd
import (
"github.com/go-errors/errors"
irma "github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/internal/keysharecore"
"github.com/privacybydesign/irmago/server"
......@@ -13,7 +14,10 @@ var keyshareServerCmd = &cobra.Command{
Use: "server",
Short: "IRMA keyshare server",
Run: func(command *cobra.Command, args []string) {
conf := configureKeyshareServer(command)
conf, err := configureKeyshareServer(command)
if err != nil {
die("failed to read configuration", err)
}
// Create main server
keyshareServer, err := keyshareserver.New(conf)
......@@ -82,7 +86,7 @@ func init() {
flags.Lookup("verbose").Header = `Other options`
}
func configureKeyshareServer(cmd *cobra.Command) *keyshareserver.Configuration {
func configureKeyshareServer(cmd *cobra.Command) (*keyshareserver.Configuration, error) {
readConfig(cmd, "keyshareserver", "keyshareserver", []string{".", "/etc/keyshareserver"}, nil)
// And build the configuration
......@@ -108,7 +112,11 @@ func configureKeyshareServer(cmd *cobra.Command) *keyshareserver.Configuration {
VerificationURL: viper.GetStringMapString("verification-url"),
}
if conf.Production && conf.DBType != keyshareserver.DBTypePostgres {
return nil, errors.New("in production mode, db-type must be postgres")
}
conf.URL = server.ReplacePortString(viper.GetString("url"), viper.GetInt("port"))
return conf
return conf, nil
}
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