Skip to content
GitLab
Menu
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
555479c7
Commit
555479c7
authored
Feb 08, 2019
by
Sietse Ringers
Browse files
Give SchemesPath and SchemesUpdateInterval sensible defaults also in irmaserver
parent
85ab5dc1
Changes
4
Hide whitespace changes
Inline
Side-by-side
internal/servercore/api.go
View file @
555479c7
...
...
@@ -17,6 +17,7 @@ import (
"github.com/privacybydesign/gabi"
"github.com/privacybydesign/gabi/big"
"github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/internal/fs"
"github.com/privacybydesign/irmago/server"
"github.com/sirupsen/logrus"
)
...
...
@@ -54,7 +55,19 @@ func (s *Server) verifyConfiguration(configuration *server.Configuration) error
irma
.
Logger
=
s
.
conf
.
Logger
if
s
.
conf
.
IrmaConfiguration
==
nil
{
var
err
error
var
(
err
error
exists
bool
)
if
s
.
conf
.
SchemesPath
==
""
{
s
.
conf
.
SchemesPath
=
server
.
DefaultSchemesPath
()
// Returns an existing path
}
if
exists
,
err
=
fs
.
PathExists
(
s
.
conf
.
SchemesPath
);
err
!=
nil
{
return
server
.
LogError
(
err
)
}
if
!
exists
{
return
server
.
LogError
(
errors
.
New
(
"Nonexisting schemes_path provided"
))
}
if
s
.
conf
.
SchemesAssetsPath
==
""
{
s
.
conf
.
IrmaConfiguration
,
err
=
irma
.
NewConfiguration
(
s
.
conf
.
SchemesPath
)
}
else
{
...
...
@@ -69,16 +82,16 @@ func (s *Server) verifyConfiguration(configuration *server.Configuration) error
}
if
len
(
s
.
conf
.
IrmaConfiguration
.
SchemeManagers
)
==
0
{
if
s
.
conf
.
DownloadDefaultSchemes
{
if
err
:=
s
.
conf
.
IrmaConfiguration
.
DownloadDefaultSchemes
();
err
!=
nil
{
return
server
.
LogError
(
err
)
}
}
else
{
return
server
.
LogError
(
errors
.
New
(
"no schemes found in irma_configuration folder "
+
s
.
conf
.
IrmaConfiguration
.
Path
))
s
.
conf
.
Logger
.
Infof
(
"No schemes found in %s, downloading default (irma-demo and pbdf)"
,
s
.
conf
.
SchemesPath
)
if
err
:=
s
.
conf
.
IrmaConfiguration
.
DownloadDefaultSchemes
();
err
!=
nil
{
return
server
.
LogError
(
err
)
}
}
if
s
.
conf
.
SchemeUpdateInterval
!=
0
{
s
.
conf
.
IrmaConfiguration
.
AutoUpdateSchemes
(
uint
(
s
.
conf
.
SchemeUpdateInterval
))
if
s
.
conf
.
SchemesUpdateInterval
==
0
{
s
.
conf
.
SchemesUpdateInterval
=
60
}
if
!
s
.
conf
.
DisableSchemesUpdate
{
s
.
conf
.
IrmaConfiguration
.
AutoUpdateSchemes
(
uint
(
s
.
conf
.
SchemesUpdateInterval
))
}
if
s
.
conf
.
IssuerPrivateKeys
==
nil
{
...
...
server/api.go
View file @
555479c7
...
...
@@ -24,14 +24,16 @@ var Logger *logrus.Logger = logrus.StandardLogger()
type
Configuration
struct
{
// irma_configuration. If not given, this will be popupated using SchemesPath.
IrmaConfiguration
*
irma
.
Configuration
`json:"-"`
// Path to IRMA schemes to parse into IrmaConfiguration (only used if IrmaConfiguration == nil)
// Path to IRMA schemes to parse into IrmaConfiguration (only used if IrmaConfiguration == nil).
// If left empty, default value is taken using DefaultSchemesPath().
// If an empty folder is specified, default schemes (irma-demo and pbdf) are downloaded into it.
SchemesPath
string
`json:"schemes_path" mapstructure:"schemes_path"`
// If specified, schemes found here are copied into SchemesPath (only used if IrmaConfiguration == nil)
SchemesAssetsPath
string
`json:"schemes_assets_path" mapstructure:"schemes_assets_path"`
//
Whether or not to download default IRMA schemes if the specified schemes path is empty
D
ownloadDefault
Schemes
bool
`json:"
schemes_download_default" mapstructure:"schemes_download_default
"`
// Update all schemes every x minutes (
0
to disable)
SchemeUpdateInterval
int
`json:"schemes_update" mapstructure:"schemes_update"`
//
Disable scheme updating
D
isable
Schemes
Update
bool
`json:"
disable_schemes_update" mapstructure:"disable_schemes_update
"`
// Update all schemes every x minutes (
default value 0 means 60) (use DisableSchemesUpdate
to disable)
Scheme
s
UpdateInterval
int
`json:"schemes_update" mapstructure:"schemes_update"`
// Path to issuer private keys to parse
IssuerPrivateKeysPath
string
`json:"privkeys" mapstructure:"privkeys"`
// Issuer private keys
...
...
server/irmad/cmd/check.go
View file @
555479c7
...
...
@@ -20,15 +20,16 @@ Specify -v to see the configuration.`,
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
// Hack: temporarily disable scheme updating to prevent verifyConfiguration() from immediately updating schemes
enabled
:=
conf
.
DisableSchemesUpdate
conf
.
DisableSchemesUpdate
=
true
if
_
,
err
:=
requestorserver
.
New
(
conf
);
err
!=
nil
{
die
(
errors
.
WrapPrefix
(
err
,
"Invalid configuration"
,
0
))
}
conf
.
SchemeUpdateInterval
=
interval
// restore previous values before printing configuration
conf
.
D
ownloadDefaultSchemes
=
download
conf
.
D
isableSchemesUpdate
=
enabled
// restore previous value before printing configuration
bts
,
_
:=
json
.
MarshalIndent
(
conf
,
""
,
" "
)
conf
.
Logger
.
Debug
(
"Configuration: "
,
string
(
bts
),
"
\n
"
)
},
...
...
server/irmad/cmd/root.go
View file @
555479c7
...
...
@@ -185,11 +185,11 @@ func configure(cmd *cobra.Command) error {
// Read configuration from flags and/or environmental variables
conf
=
&
requestorserver
.
Configuration
{
Configuration
:
&
server
.
Configuration
{
DownloadDefaultSchemes
:
true
,
// If we get passed an empty schemes-path, download default schemes into it
Schemes
Path
:
viper
.
GetString
(
"schemes-path"
),
Schemes
AssetsPath
:
viper
.
Get
String
(
"schemes-
assets-p
at
h
"
),
SchemeUpdate
Interval
:
viper
.
GetInt
(
"schemes-update"
),
IssuerPrivateKeysPath
:
viper
.
GetString
(
"privkeys"
),
SchemesPath
:
viper
.
GetString
(
"schemes-path"
),
Schemes
AssetsPath
:
viper
.
GetString
(
"schemes-
assets-
path"
),
Schemes
UpdateInterval
:
viper
.
Get
Int
(
"schemes-
upd
at
e
"
),
Disable
Scheme
s
Update
:
viper
.
GetInt
(
"schemes-update"
)
==
0
,
IssuerPrivateKeysPath
:
viper
.
GetString
(
"privkeys"
),
URL
:
viper
.
GetString
(
"url"
),
Email
:
viper
.
GetString
(
"email"
),
Logger
:
logger
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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