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
a0912d3a
Commit
a0912d3a
authored
Dec 19, 2018
by
Sietse Ringers
Browse files
Store scheme cache in /var/tmp/irmaserver
Co-authored-by:
Confiks
<
confiks@scriptbase.org
>
parent
ba4f51fc
Changes
6
Hide whitespace changes
Inline
Side-by-side
internal/sessiontest/requestor_test.go
View file @
a0912d3a
...
...
@@ -8,6 +8,7 @@ import (
"github.com/Sirupsen/logrus"
"github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/internal/fs"
"github.com/privacybydesign/irmago/internal/test"
"github.com/privacybydesign/irmago/server"
"github.com/privacybydesign/irmago/server/irmarequestor"
...
...
@@ -22,10 +23,13 @@ func StartIrmaClientServer(t *testing.T) {
logger
:=
logrus
.
New
()
logger
.
Level
=
logrus
.
WarnLevel
logger
.
Formatter
=
&
logrus
.
TextFormatter
{}
cachepath
:=
filepath
.
Join
(
testdata
,
"storage"
,
"test"
,
"cache"
)
fs
.
EnsureDirectoryExists
(
cachepath
)
require
.
NoError
(
t
,
irmarequestor
.
Initialize
(
&
server
.
Configuration
{
Logger
:
logger
,
IrmaConfigurationPath
:
filepath
.
Join
(
testdata
,
"irma_configuration"
),
IssuerPrivateKeysPath
:
filepath
.
Join
(
testdata
,
"privatekeys"
),
CachePath
:
cachepath
,
}))
mux
:=
http
.
NewServeMux
()
...
...
schemes.go
View file @
a0912d3a
...
...
@@ -7,14 +7,14 @@ type SchemeManagerPointer struct {
var
DefaultSchemeManagers
=
[
2
]
SchemeManagerPointer
{
{
Url
:
"https://privacybydesign
.foundation/
schememanager/
irma-demo
"
,
Url
:
"https://
raw.githubusercontent.com/
privacybydesign
/irma-demo-
schememanager/
master
"
,
Publickey
:
[]
byte
(
`-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEHVnmAY+kGkFZn7XXozdI4HY8GOjm
54ngh4chTfn6WsTCf2w5rprfIqML61z2VTE4k8yJ0Z1QbyW6cdaao8obTQ==
-----END PUBLIC KEY-----`
),
},
{
Url
:
"https://privacybydesign
.foundation/
schememanager/
pbdf
"
,
Url
:
"https://
raw.githubusercontent.com/
privacybydesign
/pbdf-
schememanager/
master
"
,
Publickey
:
[]
byte
(
`-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAELzHV5ipBimWpuZIDaQQd+KmNpNop
dpBeCqpDwf+Grrw9ReODb6nwlsPJ/c/gqLnc+Y3sKOAJ2bFGI+jHBSsglg==
...
...
server/api.go
View file @
a0912d3a
...
...
@@ -16,6 +16,7 @@ var Logger *logrus.Logger = logrus.StandardLogger()
type
Configuration
struct
{
IrmaConfigurationPath
string
`json:"irmaconf" mapstructure:"irmaconf"`
IssuerPrivateKeysPath
string
`json:"privatekeys" mapstructure:"privatekeys"`
CachePath
string
`json:"cachepath" mapstructure:"cachepath"`
Url
string
`json:"url" mapstructure:"url"`
Logger
*
logrus
.
Logger
`json:"-"`
IssuerPrivateKeys
map
[
irma
.
IssuerIdentifier
]
*
gabi
.
PrivateKey
`json:"-"`
...
...
server/backend/api.go
View file @
a0912d3a
...
...
@@ -29,20 +29,36 @@ func Initialize(configuration *server.Configuration) error {
if
conf
.
IrmaConfiguration
==
nil
{
var
err
error
conf
.
IrmaConfiguration
,
err
=
irma
.
NewConfiguration
(
conf
.
IrmaConfigurationPath
,
""
)
if
err
!=
nil
{
return
err
if
conf
.
CachePath
==
""
{
conf
.
CachePath
,
err
=
CachePath
()
if
err
!=
nil
{
return
err
}
conf
.
CachePath
=
filepath
.
Join
(
conf
.
CachePath
,
"irmalibrary"
)
}
if
err
=
conf
.
IrmaConfiguration
.
ParseFolder
();
err
!=
nil
{
conf
.
IrmaConfiguration
,
err
=
irma
.
NewConfiguration
(
filepath
.
Join
(
conf
.
CachePath
,
"irma_configuration"
),
conf
.
IrmaConfigurationPath
,
)
if
err
!=
nil
{
return
err
}
if
len
(
conf
.
IrmaConfiguration
.
SchemeManagers
)
==
0
{
if
conf
.
IrmaConfigurationPath
==
""
{
if
err
:=
conf
.
IrmaConfiguration
.
DownloadDefaultSchemes
();
err
!=
nil
{
return
err
}
}
else
{
if
err
=
conf
.
IrmaConfiguration
.
ParseFolder
();
err
!=
nil
{
return
err
}
}
}
if
len
(
conf
.
IrmaConfiguration
.
SchemeManagers
)
==
0
{
return
errors
.
New
(
"no schemes found in irma_configuration folder "
+
conf
.
IrmaConfiguration
.
Path
)
}
if
conf
.
IssuerPrivateKeys
==
nil
{
conf
.
IssuerPrivateKeys
=
make
(
map
[
irma
.
IssuerIdentifier
]
*
gabi
.
PrivateKey
)
}
...
...
server/backend/helpers.go
View file @
a0912d3a
package
backend
import
(
"os"
"path/filepath"
"runtime"
"strconv"
"time"
...
...
@@ -8,6 +11,7 @@ import (
"github.com/go-errors/errors"
"github.com/privacybydesign/gabi"
"github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/internal/fs"
"github.com/privacybydesign/irmago/server"
)
...
...
@@ -120,3 +124,26 @@ func chooseProtocolVersion(min, max *irma.ProtocolVersion) (*irma.ProtocolVersio
return
max
,
nil
}
}
func
CachePath
()
(
string
,
error
)
{
candidates
:=
make
([]
string
,
0
,
2
)
if
runtime
.
GOOS
!=
"windows"
{
candidates
=
append
(
candidates
,
filepath
.
Join
(
"/var/tmp"
,
"irmaserver"
))
}
candidates
=
append
(
candidates
,
filepath
.
Join
(
os
.
TempDir
(),
"irmaserver"
))
path
:=
firstWritablePath
(
candidates
)
if
path
==
""
{
return
""
,
errors
.
New
(
"No writable temporary directory found"
)
}
return
path
,
nil
}
func
firstWritablePath
(
paths
[]
string
)
string
{
for
_
,
path
:=
range
paths
{
if
err
:=
fs
.
EnsureDirectoryExists
(
path
);
err
!=
nil
{
continue
}
return
path
}
return
""
}
server/irmaserver/cmd/main.go
View file @
a0912d3a
...
...
@@ -10,6 +10,7 @@ import (
"github.com/Sirupsen/logrus"
"github.com/go-errors/errors"
"github.com/privacybydesign/irmago/server"
"github.com/privacybydesign/irmago/server/backend"
"github.com/privacybydesign/irmago/server/irmaserver"
"github.com/spf13/cobra"
"github.com/spf13/viper"
...
...
@@ -56,9 +57,15 @@ func setFlags(cmd *cobra.Command) error {
flags
:=
cmd
.
Flags
()
flags
.
SortFlags
=
false
cachepath
,
err
:=
backend
.
CachePath
()
if
err
!=
nil
{
return
err
}
flags
.
StringP
(
"config"
,
"c"
,
""
,
"Path to configuration file"
)
flags
.
StringP
(
"irmaconf"
,
"i"
,
"
./irma_configuration
"
,
"path to irma_configuration"
)
flags
.
StringP
(
"irmaconf"
,
"i"
,
""
,
"path to irma_configuration"
)
flags
.
StringP
(
"privatekeys"
,
"k"
,
""
,
"path to IRMA private keys"
)
flags
.
String
(
"cachepath"
,
cachepath
,
"Directory for writing cache files to"
)
flags
.
StringP
(
"jwtissuer"
,
"j"
,
"irmaserver"
,
"JWT issuer"
)
flags
.
StringP
(
"jwtprivatekey"
,
"w"
,
""
,
"JWT private key or path to it"
)
flags
.
StringP
(
"url"
,
"u"
,
""
,
"External URL to server to which the IRMA client connects"
)
...
...
@@ -127,8 +134,9 @@ func configure() error {
Configuration
:
&
server
.
Configuration
{
IrmaConfigurationPath
:
viper
.
GetString
(
"irmaconf"
),
IssuerPrivateKeysPath
:
viper
.
GetString
(
"privatekeys"
),
Url
:
viper
.
GetString
(
"url"
),
Logger
:
logger
,
CachePath
:
viper
.
GetString
(
"cachepath"
),
Url
:
viper
.
GetString
(
"url"
),
Logger
:
logger
,
},
Port
:
viper
.
GetInt
(
"port"
),
DisableRequestorAuthentication
:
viper
.
GetBool
(
"noauth"
),
...
...
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