Commit 1b2d8bb2 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Rename irmaserver package to irmad

parent 6c6cec98
package irmaserver package irmad
import ( import (
"net/http" "net/http"
......
package main
import (
"encoding/json"
"github.com/go-errors/errors"
"github.com/privacybydesign/irmago/server/irmad"
"github.com/spf13/cobra"
)
var CheckCommand = &cobra.Command{
Use: "check",
Short: "Check server configuration correctness",
Long: `check reads the server configuration like the main command does, from a
configuration file, command line flags, or environmental variables, and checks
that the configuration is valid.
Specify -v to see the configuration.`,
Run: func(command *cobra.Command, args []string) {
if err := configure(command); err != nil {
die(errors.WrapPrefix(err, "Failed to read configuration from file, args, or env vars", 0))
}
interval := conf.SchemeUpdateInterval
download := conf.DownloadDefaultSchemes
conf.SchemeUpdateInterval = 0 // Hack: put this to 0 to prevent verifyConfiguration() from immediately updating schemes
conf.DownloadDefaultSchemes = false // and this to false to prevent default scheme downloading
if _, err := irmad.New(conf); err != nil {
die(errors.WrapPrefix(err, "Invalid configuration", 0))
}
conf.SchemeUpdateInterval = interval // restore previous values before printing configuration
conf.DownloadDefaultSchemes = download
bts, _ := json.MarshalIndent(conf, "", " ")
conf.Logger.Debug("Configuration: ", string(bts), "\n")
},
}
func init() {
RootCommand.AddCommand(CheckCommand)
if err := setFlags(CheckCommand); err != nil {
die(errors.WrapPrefix(err, "Failed to attach flags to "+CheckCommand.Name()+" command", 0))
}
}
// Executable for the irmaserver. // Executable for the irmad.
package main package main
import ( import (
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
"github.com/go-errors/errors" "github.com/go-errors/errors"
"github.com/privacybydesign/irmago/server" "github.com/privacybydesign/irmago/server"
"github.com/privacybydesign/irmago/server/irmaserver" "github.com/privacybydesign/irmago/server/irmad"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
...@@ -17,7 +17,7 @@ import ( ...@@ -17,7 +17,7 @@ import (
) )
var logger = logrus.StandardLogger() var logger = logrus.StandardLogger()
var conf *irmaserver.Configuration var conf *irmad.Configuration
var RootCommand = &cobra.Command{ var RootCommand = &cobra.Command{
Use: "irmad", Use: "irmad",
...@@ -26,7 +26,7 @@ var RootCommand = &cobra.Command{ ...@@ -26,7 +26,7 @@ var RootCommand = &cobra.Command{
if err := configure(command); err != nil { if err := configure(command); err != nil {
die(errors.WrapPrefix(err, "Failed to read configuration", 0)) die(errors.WrapPrefix(err, "Failed to read configuration", 0))
} }
serv, err := irmaserver.New(conf) serv, err := irmad.New(conf)
if err != nil { if err != nil {
die(errors.WrapPrefix(err, "Failed to configure server", 0)) die(errors.WrapPrefix(err, "Failed to configure server", 0))
} }
...@@ -36,52 +36,15 @@ var RootCommand = &cobra.Command{ ...@@ -36,52 +36,15 @@ var RootCommand = &cobra.Command{
}, },
} }
var RunCommand = &cobra.Command{
Use: "run",
Short: "Run server (same as specifying no command)",
Run: RootCommand.Run,
}
var CheckCommand = &cobra.Command{
Use: "check",
Short: "Check server configuration correctness",
Long: `check reads the server configuration like the main command does, from a
configuration file, command line flags, or environmental variables, and checks
that the configuration is valid.
Specify -v to see the configuration.`,
Run: func(command *cobra.Command, args []string) {
if err := configure(command); err != nil {
die(errors.WrapPrefix(err, "Failed to read configuration from file, args, or env vars", 0))
}
interval := conf.SchemeUpdateInterval
download := conf.DownloadDefaultSchemes
conf.SchemeUpdateInterval = 0 // Hack: put this to 0 to prevent verifyConfiguration() from immediately updating schemes
conf.DownloadDefaultSchemes = false // and this to false to prevent default scheme downloading
if _, err := irmaserver.New(conf); err != nil {
die(errors.WrapPrefix(err, "Invalid configuration", 0))
}
conf.SchemeUpdateInterval = interval // restore previous values before printing configuration
conf.DownloadDefaultSchemes = download
bts, _ := json.MarshalIndent(conf, "", " ")
conf.Logger.Debug("Configuration: ", string(bts), "\n")
},
}
func main() { func main() {
logger.Level = logrus.InfoLevel logger.Level = logrus.InfoLevel
logger.SetFormatter(&prefixed.TextFormatter{ logger.SetFormatter(&prefixed.TextFormatter{
FullTimestamp: true, FullTimestamp: true,
}) })
RootCommand.AddCommand(CheckCommand, RunCommand) if err := setFlags(RootCommand); err != nil {
die(errors.WrapPrefix(err, "Failed to attach flags to "+RootCommand.Name()+" command", 0))
for _, cmd := range []*cobra.Command{RootCommand, CheckCommand, RunCommand} {
if err := setFlags(cmd); err != nil {
die(errors.WrapPrefix(err, "Failed to attach flags to "+cmd.Name()+" command", 0))
}
} }
if err := RootCommand.Execute(); err != nil { if err := RootCommand.Execute(); err != nil {
die(errors.WrapPrefix(err, "Failed to execute command", 0)) die(errors.WrapPrefix(err, "Failed to execute command", 0))
} }
...@@ -215,7 +178,7 @@ func configure(cmd *cobra.Command) error { ...@@ -215,7 +178,7 @@ func configure(cmd *cobra.Command) error {
} }
// Read configuration from flags and/or environmental variables // Read configuration from flags and/or environmental variables
conf = &irmaserver.Configuration{ conf = &irmad.Configuration{
Configuration: &server.Configuration{ Configuration: &server.Configuration{
DownloadDefaultSchemes: true, // If we get passed an empty schemes-path, download default schemes into it DownloadDefaultSchemes: true, // If we get passed an empty schemes-path, download default schemes into it
SchemesPath: viper.GetString("schemes-path"), SchemesPath: viper.GetString("schemes-path"),
...@@ -225,7 +188,7 @@ func configure(cmd *cobra.Command) error { ...@@ -225,7 +188,7 @@ func configure(cmd *cobra.Command) error {
URL: viper.GetString("url"), URL: viper.GetString("url"),
Logger: logger, Logger: logger,
}, },
Permissions: irmaserver.Permissions{ Permissions: irmad.Permissions{
Disclosing: handlePermission("disclose-perms"), Disclosing: handlePermission("disclose-perms"),
Signing: handlePermission("sign-perms"), Signing: handlePermission("sign-perms"),
Issuing: handlePermission("issue-perms"), Issuing: handlePermission("issue-perms"),
...@@ -235,7 +198,7 @@ func configure(cmd *cobra.Command) error { ...@@ -235,7 +198,7 @@ func configure(cmd *cobra.Command) error {
ClientListenAddress: viper.GetString("client-listen-addr"), ClientListenAddress: viper.GetString("client-listen-addr"),
ClientPort: viper.GetInt("client-port"), ClientPort: viper.GetInt("client-port"),
DisableRequestorAuthentication: viper.GetBool("no-auth"), DisableRequestorAuthentication: viper.GetBool("no-auth"),
Requestors: make(map[string]irmaserver.Requestor), Requestors: make(map[string]irmad.Requestor),
JwtIssuer: viper.GetString("jwt-issuer"), JwtIssuer: viper.GetString("jwt-issuer"),
JwtPrivateKey: viper.GetString("jwt-privkey"), JwtPrivateKey: viper.GetString("jwt-privkey"),
JwtPrivateKeyFile: viper.GetString("jwt-privkey-file"), JwtPrivateKeyFile: viper.GetString("jwt-privkey-file"),
......
package main
import (
"github.com/go-errors/errors"
"github.com/spf13/cobra"
)
var RunCommand = &cobra.Command{
Use: "run",
Short: "Run server (same as specifying no command)",
Run: RootCommand.Run,
}
func init() {
RootCommand.AddCommand(RunCommand)
if err := setFlags(RunCommand); err != nil {
die(errors.WrapPrefix(err, "Failed to attach flags to "+RunCommand.Name()+" command", 0))
}
}
package irmaserver package irmad
import ( import (
"crypto/rsa" "crypto/rsa"
......
// Package irmaserver is a server allowing IRMA verifiers, issuers or attribute-based signature applications (the requestor) to perform IRMA sessions with irmaclient instances (i.e. the IRMA app). It exposes a RESTful protocol with which the requestor can start and manage the session as well as HTTP endpoints for the irmaclient. // Package irmaserver is a server allowing IRMA verifiers, issuers or attribute-based signature applications (the requestor) to perform IRMA sessions with irmaclient instances (i.e. the IRMA app). It exposes a RESTful protocol with which the requestor can start and manage the session as well as HTTP endpoints for the irmaclient.
package irmaserver package irmad
import ( import (
"crypto/tls" "crypto/tls"
......
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