Commit f3c64f10 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Make downloading default schemes configurable in library

parent dd543638
......@@ -23,7 +23,7 @@ dpBeCqpDwf+Grrw9ReODb6nwlsPJ/c/gqLnc+Y3sKOAJ2bFGI+jHBSsglg==
}
func (conf *Configuration) DownloadDefaultSchemes() error {
Logger.Info("No schemes found in irma_configuration, downloading default schemes")
Logger.Info("downloading default schemes")
for _, s := range DefaultSchemeManagers {
Logger.Debugf("Downloading scheme at %s", s.Url)
scheme, err := DownloadSchemeManager(s.Url)
......
......@@ -24,8 +24,10 @@ type Configuration struct {
IrmaConfiguration *irma.Configuration `json:"-"`
// Path to schemes to parse (only used if IrmaConfiguration is not given)
IrmaConfigurationPath string `json:"irmaconf" mapstructure:"irmaconf"`
// Path to writable dir to write cache to (only used if IrmaConfiguration is not give)
// Path to writable dir to write cache to (only used if IrmaConfiguration is not given)
CachePath string `json:"cachepath" mapstructure:"cachepath"`
// Whether or not to download default IRMA schemes if the specified irma_configuration is empty
DownloadDefaultSchemes bool
// Path to issuer private keys to parse
IssuerPrivateKeysPath string `json:"privatekeys" mapstructure:"privatekeys"`
// Issuer private keys
......@@ -173,9 +175,9 @@ func LocalIP() (string, error) {
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("/var/tmp", "irma"))
}
candidates = append(candidates, filepath.Join(os.TempDir(), "irmaserver"))
candidates = append(candidates, filepath.Join(os.TempDir(), "irma"))
path := firstWritablePath(candidates)
if path == "" {
return "", errors.New("No writable temporary directory found")
......
......@@ -44,21 +44,21 @@ func Initialize(configuration *server.Configuration) error {
if err != nil {
return err
}
if conf.IrmaConfigurationPath == "" {
if err = conf.IrmaConfiguration.ParseFolder(); err != nil {
return err
}
}
if len(conf.IrmaConfiguration.SchemeManagers) == 0 {
if conf.DownloadDefaultSchemes {
if err := conf.IrmaConfiguration.DownloadDefaultSchemes(); err != nil {
return err
}
} else {
if err = conf.IrmaConfiguration.ParseFolder(); err != nil {
return err
}
return errors.New("no schemes found in irma_configuration folder " + conf.IrmaConfiguration.Path)
}
}
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)
}
......
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