Commit 02ea4239 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Change package structure

parent 57897fbd
package main package cmd
import ( import (
"encoding/json" "encoding/json"
"github.com/go-errors/errors" "github.com/go-errors/errors"
"github.com/privacybydesign/irmago/server/irmad" "github.com/privacybydesign/irmago/server/requestorserver"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
...@@ -24,7 +24,7 @@ Specify -v to see the configuration.`, ...@@ -24,7 +24,7 @@ Specify -v to see the configuration.`,
download := conf.DownloadDefaultSchemes download := conf.DownloadDefaultSchemes
conf.SchemeUpdateInterval = 0 // Hack: put this to 0 to prevent verifyConfiguration() from immediately updating schemes 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 conf.DownloadDefaultSchemes = false // and this to false to prevent default scheme downloading
if _, err := irmad.New(conf); err != nil { if _, err := requestorserver.New(conf); err != nil {
die(errors.WrapPrefix(err, "Invalid configuration", 0)) die(errors.WrapPrefix(err, "Invalid configuration", 0))
} }
conf.SchemeUpdateInterval = interval // restore previous values before printing configuration conf.SchemeUpdateInterval = interval // restore previous values before printing configuration
......
// Executable for the irmad. // Executable for the irmad.
package main package cmd
import ( import (
"encoding/json" "encoding/json"
"fmt"
"io/ioutil" "io/ioutil"
"os"
"path/filepath" "path/filepath"
"strings" "strings"
"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/irmad" "github.com/privacybydesign/irmago/server/requestorserver"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/x-cray/logrus-prefixed-formatter"
) )
var logger = logrus.StandardLogger() var logger = logrus.StandardLogger()
var conf *irmad.Configuration var conf *requestorserver.Configuration
var RootCommand = &cobra.Command{ var RootCommand = &cobra.Command{
Use: "irmad", Use: "irmad",
...@@ -26,7 +27,7 @@ var RootCommand = &cobra.Command{ ...@@ -26,7 +27,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 := irmad.New(conf) serv, err := requestorserver.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,17 +37,12 @@ var RootCommand = &cobra.Command{ ...@@ -36,17 +37,12 @@ var RootCommand = &cobra.Command{
}, },
} }
func main() { // Execute adds all child commands to the root command sets flags appropriately.
logger.Level = logrus.InfoLevel // This is called by main.main(). It only needs to happen once to the rootCmd.
logger.SetFormatter(&prefixed.TextFormatter{ func Execute() {
FullTimestamp: true,
})
if err := setFlags(RootCommand); err != nil {
die(errors.WrapPrefix(err, "Failed to attach flags to "+RootCommand.Name()+" command", 0))
}
if err := RootCommand.Execute(); err != nil { if err := RootCommand.Execute(); err != nil {
die(errors.WrapPrefix(err, "Failed to execute command", 0)) fmt.Println(err)
os.Exit(-1)
} }
} }
...@@ -178,7 +174,7 @@ func configure(cmd *cobra.Command) error { ...@@ -178,7 +174,7 @@ func configure(cmd *cobra.Command) error {
} }
// Read configuration from flags and/or environmental variables // Read configuration from flags and/or environmental variables
conf = &irmad.Configuration{ conf = &requestorserver.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"),
...@@ -188,7 +184,7 @@ func configure(cmd *cobra.Command) error { ...@@ -188,7 +184,7 @@ func configure(cmd *cobra.Command) error {
URL: viper.GetString("url"), URL: viper.GetString("url"),
Logger: logger, Logger: logger,
}, },
Permissions: irmad.Permissions{ Permissions: requestorserver.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"),
...@@ -198,7 +194,7 @@ func configure(cmd *cobra.Command) error { ...@@ -198,7 +194,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]irmad.Requestor), Requestors: make(map[string]requestorserver.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 package cmd
import ( import (
"github.com/go-errors/errors" "github.com/go-errors/errors"
......
// Executable for the irmad.
package main
import "github.com/privacybydesign/irmago/server/irmad/cmd"
func main() {
cmd.Execute()
}
package irmad package requestorserver
import ( import (
"net/http" "net/http"
......
package irmad package requestorserver
import ( import (
"crypto/rsa" "crypto/rsa"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// applications (the requestor) to perform IRMA sessions with irmaclient instances (i.e. the IRMA // 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 // app). It exposes a RESTful protocol with which the requestor can start and manage the session as
// well as HTTP endpoints for the irmaclient. // well as HTTP endpoints for the irmaclient.
package irmad package requestorserver
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