Commit 52457ddb authored by Sietse Ringers's avatar Sietse Ringers
Browse files

refactor: rename keyshare subpackages and irma commands

parent 19cba23a
......@@ -10,7 +10,7 @@ import (
"github.com/go-chi/chi"
"github.com/privacybydesign/irmago/internal/keysharecore"
"github.com/privacybydesign/irmago/internal/test"
"github.com/privacybydesign/irmago/server/keyshare/app"
"github.com/privacybydesign/irmago/server/keyshare/keyshareserver"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
......@@ -19,8 +19,8 @@ import (
var keyshareServ *http.Server
func StartKeyshareServer(t *testing.T, l *logrus.Logger) {
db := app.NewMemoryDatabase()
_, err := db.NewUser(app.KeyshareUserData{
db := keyshareserver.NewMemoryDatabase()
_, err := db.NewUser(keyshareserver.KeyshareUserData{
Username: "",
Coredata: keysharecore.EncryptedKeysharePacket{},
})
......@@ -29,14 +29,14 @@ func StartKeyshareServer(t *testing.T, l *logrus.Logger) {
p, err := base64.StdEncoding.DecodeString("YWJjZK4w5SC+7D4lDrhiJGvB1iwxSeF90dGGPoGqqG7g3ivbfHibOdkKoOTZPbFlttBzn2EJgaEsL24Re8OWWWw5pd31/GCd14RXcb9Wy2oWhbr0pvJDLpIxXZt/qiQC0nJiIAYWLGZOdj5o0irDfqP1CSfw3IoKkVEl4lHRj0LCeINJIOpEfGlFtl4DHlWu8SMQFV1AIm3Gv64XzGncdkclVd41ti7cicBrcK8N2u9WvY/jCS4/Lxa2syp/O4IY")
require.NoError(t, err)
copy(ep[:], p)
_, err = db.NewUser(app.KeyshareUserData{
_, err = db.NewUser(keyshareserver.KeyshareUserData{
Username: "testusername",
Coredata: ep,
})
require.NoError(t, err)
testdataPath := test.FindTestdataFolder(t)
s, err := app.New(&app.Configuration{
s, err := keyshareserver.New(&keyshareserver.Configuration{
SchemesPath: filepath.Join(testdataPath, "irma_configuration"),
IssuerPrivateKeysPath: filepath.Join(testdataPath, "privatekeys"),
URL: "http://localhost:8080/irma_keyshare_server/api/v1/",
......
......@@ -19,17 +19,17 @@ import (
irma "github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/internal/common"
"github.com/privacybydesign/irmago/server"
"github.com/privacybydesign/irmago/server/keyshare/myirma"
"github.com/privacybydesign/irmago/server/keyshare/myirmaserver"
"github.com/sietseringers/cobra"
"github.com/sietseringers/viper"
"github.com/sirupsen/logrus"
)
var confKeyshareMyirma *myirma.Configuration
var confKeyshareMyirma *myirmaserver.Configuration
var myirmadCmd = &cobra.Command{
Use: "myirma",
Short: "IRMA keyshare server myirma component",
Short: "IRMA keyshare myirma server",
Run: func(command *cobra.Command, args []string) {
configureMyirmad(command)
......@@ -47,7 +47,7 @@ var myirmadCmd = &cobra.Command{
}
// Create main server
myirmaServer, err := myirma.New(confKeyshareMyirma)
myirmaServer, err := myirmaserver.New(confKeyshareMyirma)
if err != nil {
die("", err)
}
......@@ -114,7 +114,7 @@ func init() {
flags.String("path-prefix", "/", "prefix to listen path")
flags.Lookup("port").Header = `Server address and port to listen on`
flags.String("db-type", myirma.DatabaseTypePostgres, "Type of database to connect keyshare server to")
flags.String("db-type", myirmaserver.DatabaseTypePostgres, "Type of database to connect keyshare server to")
flags.String("db", "", "Database server connection string")
flags.Lookup("db-type").Header = `Database configuration`
......@@ -207,7 +207,7 @@ func configureMyirmad(cmd *cobra.Command) {
}
// And build the configuration
confKeyshareMyirma = &myirma.Configuration{
confKeyshareMyirma = &myirmaserver.Configuration{
SchemesPath: viper.GetString("schemes-path"),
SchemesAssetsPath: viper.GetString("schemes-assets-path"),
SchemesUpdateInterval: viper.GetInt("schemes-update"),
......@@ -218,7 +218,7 @@ func configureMyirmad(cmd *cobra.Command) {
StaticPath: viper.GetString("static-path"),
StaticPrefix: viper.GetString("static-prefix"),
DBType: myirma.DatabaseType(viper.GetString("db-type")),
DBType: myirmaserver.DatabaseType(viper.GetString("db-type")),
DBConnstring: viper.GetString("db"),
KeyshareAttributeNames: viper.GetStringSlice("keyshare-attributes"),
......
......@@ -4,7 +4,7 @@ import "github.com/sietseringers/cobra"
var keyshareRoot = &cobra.Command{
Use: "keyshare",
Short: "IRMA keyshare server",
Short: "IRMA keyshare server components",
}
func init() {
......
......@@ -19,17 +19,17 @@ import (
irma "github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/internal/common"
"github.com/privacybydesign/irmago/server"
"github.com/privacybydesign/irmago/server/keyshare/app"
"github.com/privacybydesign/irmago/server/keyshare/keyshareserver"
"github.com/sietseringers/cobra"
"github.com/sietseringers/viper"
"github.com/sirupsen/logrus"
)
var confKeysharePhone *app.Configuration
var confKeyshareServer *keyshareserver.Configuration
var keysharedCmd = &cobra.Command{
Use: "app",
Short: "IRMA keyshare server app-talking component",
Use: "server",
Short: "IRMA keyshare server",
Run: func(command *cobra.Command, args []string) {
configureKeyshared(command)
......@@ -47,7 +47,7 @@ var keysharedCmd = &cobra.Command{
}
// Create main server
keyshareServer, err := app.New(confKeysharePhone)
keyshareServer, err := keyshareserver.New(confKeyshareServer)
if err != nil {
die("", err)
}
......@@ -71,22 +71,22 @@ var keysharedCmd = &cobra.Command{
} else {
err = serv.ListenAndServe()
}
confKeysharePhone.Logger.Debug("Server stopped")
confKeyshareServer.Logger.Debug("Server stopped")
stopped <- struct{}{}
}()
for {
select {
case <-interrupt:
confKeysharePhone.Logger.Debug("Caught interrupt")
confKeyshareServer.Logger.Debug("Caught interrupt")
err = serv.Shutdown(context.Background())
if err != nil {
_ = server.LogError(err)
}
keyshareServer.Stop()
confKeysharePhone.Logger.Debug("Sent stop signal to server")
confKeyshareServer.Logger.Debug("Sent stop signal to server")
case <-stopped:
confKeysharePhone.Logger.Info("Exiting")
confKeyshareServer.Logger.Info("Exiting")
close(stopped)
close(interrupt)
return
......@@ -112,7 +112,7 @@ func init() {
flags.String("path-prefix", "/", "prefix to listen path")
flags.Lookup("port").Header = `Server address and port to listen on`
flags.String("db-type", app.DatabaseTypePostgres, "Type of database to connect keyshare server to")
flags.String("db-type", keyshareserver.DatabaseTypePostgres, "Type of database to connect keyshare server to")
flags.String("db", "", "Database server connection string")
flags.Lookup("db-type").Header = `Database configuration`
......@@ -208,7 +208,7 @@ func configureKeyshared(cmd *cobra.Command) {
}
// And build the configuration
confKeysharePhone = &app.Configuration{
confKeyshareServer = &keyshareserver.Configuration{
SchemesPath: viper.GetString("schemes-path"),
SchemesAssetsPath: viper.GetString("schemes-assets-path"),
SchemesUpdateInterval: viper.GetInt("schemes-update"),
......@@ -217,7 +217,7 @@ func configureKeyshared(cmd *cobra.Command) {
URL: string(regexp.MustCompile("(https?://[^/]*):port").ReplaceAll([]byte(viper.GetString("url")), []byte("$1:"+strconv.Itoa(viper.GetInt("port"))))),
DisableTLS: viper.GetBool("no-tls"),
DBType: app.DatabaseType(viper.GetString("db-type")),
DBType: keyshareserver.DatabaseType(viper.GetString("db-type")),
DBConnstring: viper.GetString("db"),
JwtKeyID: viper.GetInt("jwt-privkey-id"),
......
......@@ -8,21 +8,21 @@ import (
"github.com/go-errors/errors"
irma "github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/server"
"github.com/privacybydesign/irmago/server/keyshare/task"
"github.com/privacybydesign/irmago/server/keyshare/taskserver"
"github.com/sietseringers/cobra"
"github.com/sietseringers/viper"
"github.com/sirupsen/logrus"
)
var confKeyshareTask *task.Configuration
var confKeyshareTask *taskserver.Configuration
var keyshareTaskCmd = &cobra.Command{
Use: "task",
Short: "IRMA keyshare server background tasks",
Short: "IRMA keyshare background task server",
Run: func(command *cobra.Command, args []string) {
configureKeyshareTask(command)
task, err := task.New(confKeyshareTask)
task, err := taskserver.New(confKeyshareTask)
if err != nil {
die("", err)
}
......@@ -120,7 +120,7 @@ func configureKeyshareTask(cmd *cobra.Command) {
emailAuth = smtp.PlainAuth("", viper.GetString("email-username"), viper.GetString("email-password"), viper.GetString("email-hostname"))
}
confKeyshareTask = &task.Configuration{
confKeyshareTask = &taskserver.Configuration{
DBConnstring: viper.GetString("db"),
ExpiryDelay: viper.GetInt("expiry-delay"),
......
package app
package keyshareserver
import (
"encoding/binary"
......
package app
package keyshareserver
import (
"errors"
......
//+build !local_tests
package app
package keyshareserver
import (
"database/sql"
......
package app
package keyshareserver
import (
"bytes"
......@@ -116,7 +116,7 @@ func (s *Server) Handler() http.Handler {
if s.conf.Verbose >= 2 {
opts := server.LogOptions{Response: true, Headers: true, From: false, EncodeBinary: true}
router.Use(server.LogMiddleware("keyshare-app", opts))
router.Use(server.LogMiddleware("keyshareserver", opts))
}
// Registration
......
//+build !local_tests
package app
package keyshareserver
import (
"bytes"
......
package myirma
package myirmaserver
import (
"html/template"
......
Supports Markdown
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