Commit 85ab5dc1 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Add email flag

parent fc0b31a5
......@@ -123,6 +123,17 @@ func (s *Server) verifyConfiguration(configuration *server.Configuration) error
s.conf.Logger.Warn("No url parameter specified in configuration; unless an url is elsewhere prepended in the QR, the IRMA client will not be able to connect")
}
if s.conf.Email != "" {
// Very basic sanity checks
if !strings.Contains(s.conf.Email, "@") || strings.Contains(s.conf.Email, "\n") {
return server.LogError(errors.New("Invalid email address specified"))
}
t := irma.NewHTTPTransport("https://metrics.privacybydesign.foundation/history/email")
t.SetHeader("User-Agent", "irmaserver")
var x string
_ = t.Post("", &x, s.conf.Email)
}
return nil
}
......
......@@ -40,6 +40,10 @@ type Configuration struct {
URL string `json:"url" mapstructure:"url"`
// Logging
Logger *logrus.Logger `json:"-"`
// (Optional) email address of server admin, for incidental notifications such as breaking API changes
// See https://github.com/privacybydesign/irmago/tree/master/server#specifying-an-email-address
// for more information
Email string
}
// SessionResult contains session information such as the session status, type, possible errors,
......
......@@ -118,6 +118,10 @@ using the corresponding "-file" flag.`
flags.String("client-tls-privkey-file", "", "path to TLS private key for IRMA app server")
flags.Lookup("tls-cert").Header = "TLS configuration. Leave empty to disable TLS."
flags.String("email", "", "Email address of server admin, for incidental notifications such as breaking API changes")
flags.Bool("no-email", true, "Opt out of prodiding an email address with --email")
flags.Lookup("email").Header = "Email address. You are encouraged to provide your email address, so you can be notified of important changes. See README for more info."
flags.CountP("verbose", "v", "verbose (repeatable)")
flags.BoolP("quiet", "q", false, "quiet")
flags.Bool("log-json", false, "Log in JSON format")
......@@ -139,6 +143,7 @@ func configure(cmd *cobra.Command) error {
if viper.GetBool("production") {
viper.SetDefault("no-auth", false)
viper.SetDefault("no-email", false)
viper.SetDefault("url", "")
}
......@@ -186,6 +191,7 @@ func configure(cmd *cobra.Command) error {
SchemeUpdateInterval: viper.GetInt("schemes-update"),
IssuerPrivateKeysPath: viper.GetString("privkeys"),
URL: viper.GetString("url"),
Email: viper.GetString("email"),
Logger: logger,
},
Permissions: requestorserver.Permissions{
......@@ -219,6 +225,13 @@ func configure(cmd *cobra.Command) error {
Production: viper.GetBool("production"),
}
if !viper.GetBool("no-email") && conf.Email == "" {
return errors.New("In production mode it is required to specify either an email address with the --email flag, or explicitly opting out with --no-email. See help or README for more info.")
}
if viper.GetBool("no-email") && conf.Email != "" {
return errors.New("--no-email cannot be combined with --email")
}
// Handle requestors
if len(viper.GetStringMap("requestors")) > 0 { // First read config file
if err := viper.UnmarshalKey("requestors", &conf.Requestors); err != 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