Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
52457ddb
Commit
52457ddb
authored
Apr 14, 2021
by
Sietse Ringers
Browse files
refactor: rename keyshare subpackages and irma commands
parent
19cba23a
Changes
34
Hide whitespace changes
Inline
Side-by-side
internal/testkeyshare/testkeyshare.go
View file @
52457ddb
...
...
@@ -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/"
,
...
...
irma/cmd/keyshare-myirma.go
View file @
52457ddb
...
...
@@ -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/myirma
server
"
"github.com/sietseringers/cobra"
"github.com/sietseringers/viper"
"github.com/sirupsen/logrus"
)
var
confKeyshareMyirma
*
myirma
.
Configuration
var
confKeyshareMyirma
*
myirma
server
.
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
:=
myirma
server
.
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"
,
myirma
server
.
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
=
&
myirma
server
.
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
:
myirma
server
.
DatabaseType
(
viper
.
GetString
(
"db-type"
)),
DBConnstring
:
viper
.
GetString
(
"db"
),
KeyshareAttributeNames
:
viper
.
GetStringSlice
(
"keyshare-attributes"
),
...
...
irma/cmd/keyshare-root.go
View file @
52457ddb
...
...
@@ -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
()
{
...
...
irma/cmd/keyshare-
app
.go
→
irma/cmd/keyshare-
server
.go
View file @
52457ddb
...
...
@@ -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
confKeyshare
Phone
*
app
.
Configuration
var
confKeyshare
Server
*
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
(
confKeyshare
Phone
)
keyshareServer
,
err
:=
keyshareserver
.
New
(
confKeyshare
Server
)
if
err
!=
nil
{
die
(
""
,
err
)
}
...
...
@@ -71,22 +71,22 @@ var keysharedCmd = &cobra.Command{
}
else
{
err
=
serv
.
ListenAndServe
()
}
confKeyshare
Phone
.
Logger
.
Debug
(
"Server stopped"
)
confKeyshare
Server
.
Logger
.
Debug
(
"Server stopped"
)
stopped
<-
struct
{}{}
}()
for
{
select
{
case
<-
interrupt
:
confKeyshare
Phone
.
Logger
.
Debug
(
"Caught interrupt"
)
confKeyshare
Server
.
Logger
.
Debug
(
"Caught interrupt"
)
err
=
serv
.
Shutdown
(
context
.
Background
())
if
err
!=
nil
{
_
=
server
.
LogError
(
err
)
}
keyshareServer
.
Stop
()
confKeyshare
Phone
.
Logger
.
Debug
(
"Sent stop signal to server"
)
confKeyshare
Server
.
Logger
.
Debug
(
"Sent stop signal to server"
)
case
<-
stopped
:
confKeyshare
Phone
.
Logger
.
Info
(
"Exiting"
)
confKeyshare
Server
.
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
confKeyshare
Phone
=
&
app
.
Configuration
{
confKeyshare
Server
=
&
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"
),
...
...
irma/cmd/keyshare-task.go
View file @
52457ddb
...
...
@@ -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/task
server
"
"github.com/sietseringers/cobra"
"github.com/sietseringers/viper"
"github.com/sirupsen/logrus"
)
var
confKeyshareTask
*
task
.
Configuration
var
confKeyshareTask
*
task
server
.
Configuration
var
keyshareTaskCmd
=
&
cobra
.
Command
{
Use
:
"task"
,
Short
:
"IRMA keyshare
server
background task
s
"
,
Short
:
"IRMA keyshare background task
server
"
,
Run
:
func
(
command
*
cobra
.
Command
,
args
[]
string
)
{
configureKeyshareTask
(
command
)
task
,
err
:=
task
.
New
(
confKeyshareTask
)
task
,
err
:=
task
server
.
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
=
&
task
server
.
Configuration
{
DBConnstring
:
viper
.
GetString
(
"db"
),
ExpiryDelay
:
viper
.
GetInt
(
"expiry-delay"
),
...
...
server/keyshare/
app
/cleanup.sql
→
server/keyshare/
keyshareserver
/cleanup.sql
View file @
52457ddb
File moved
server/keyshare/
app
/conf.go
→
server/keyshare/
keyshareserver
/conf.go
View file @
52457ddb
package
app
package
keyshareserver
import
(
"encoding/binary"
...
...
server/keyshare/
app
/conf_test.go
→
server/keyshare/
keyshareserver
/conf_test.go
View file @
52457ddb
package
app
package
keyshareserver
import
(
"html/template"
...
...
server/keyshare/
app
/db.go
→
server/keyshare/
keyshareserver
/db.go
View file @
52457ddb
package
app
package
keyshareserver
import
(
"errors"
...
...
server/keyshare/
app
/memorydb.go
→
server/keyshare/
keyshareserver
/memorydb.go
View file @
52457ddb
package
app
package
keyshareserver
import
(
"sync"
...
...
server/keyshare/
app
/memorydb_test.go
→
server/keyshare/
keyshareserver
/memorydb_test.go
View file @
52457ddb
package
app
package
keyshareserver
import
(
"testing"
...
...
server/keyshare/
app
/postgresdb.go
→
server/keyshare/
keyshareserver
/postgresdb.go
View file @
52457ddb
package
app
package
keyshareserver
import
(
"database/sql"
...
...
server/keyshare/
app
/postgresdb_test.go
→
server/keyshare/
keyshareserver
/postgresdb_test.go
View file @
52457ddb
//+build !local_tests
package
app
package
keyshareserver
import
(
"database/sql"
...
...
server/keyshare/
app
/schema.sql
→
server/keyshare/
keyshareserver
/schema.sql
View file @
52457ddb
File moved
server/keyshare/
app
/server.go
→
server/keyshare/
keyshareserver
/server.go
View file @
52457ddb
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
(
"keyshare
server
"
,
opts
))
}
// Registration
...
...
server/keyshare/
app
/server_email_test.go
→
server/keyshare/
keyshareserver
/server_email_test.go
View file @
52457ddb
//+build !local_tests
package
app
package
keyshareserver
import
(
"bytes"
...
...
server/keyshare/
app
/server_test.go
→
server/keyshare/
keyshareserver
/server_test.go
View file @
52457ddb
package
app
package
keyshareserver
import
(
"bytes"
...
...
server/keyshare/myirma/README
→
server/keyshare/myirma
server
/README
View file @
52457ddb
File moved
server/keyshare/myirma/conf.go
→
server/keyshare/myirma
server
/conf.go
View file @
52457ddb
package
myirma
package
myirma
server
import
(
"html/template"
...
...
server/keyshare/myirma/conf_test.go
→
server/keyshare/myirma
server
/conf_test.go
View file @
52457ddb
package
myirma
package
myirma
server
import
(
"path/filepath"
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment