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== ...@@ -23,7 +23,7 @@ dpBeCqpDwf+Grrw9ReODb6nwlsPJ/c/gqLnc+Y3sKOAJ2bFGI+jHBSsglg==
} }
func (conf *Configuration) DownloadDefaultSchemes() error { 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 { for _, s := range DefaultSchemeManagers {
Logger.Debugf("Downloading scheme at %s", s.Url) Logger.Debugf("Downloading scheme at %s", s.Url)
scheme, err := DownloadSchemeManager(s.Url) scheme, err := DownloadSchemeManager(s.Url)
......
...@@ -24,8 +24,10 @@ type Configuration struct { ...@@ -24,8 +24,10 @@ type Configuration struct {
IrmaConfiguration *irma.Configuration `json:"-"` IrmaConfiguration *irma.Configuration `json:"-"`
// Path to schemes to parse (only used if IrmaConfiguration is not given) // Path to schemes to parse (only used if IrmaConfiguration is not given)
IrmaConfigurationPath string `json:"irmaconf" mapstructure:"irmaconf"` 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"` 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 // Path to issuer private keys to parse
IssuerPrivateKeysPath string `json:"privatekeys" mapstructure:"privatekeys"` IssuerPrivateKeysPath string `json:"privatekeys" mapstructure:"privatekeys"`
// Issuer private keys // Issuer private keys
...@@ -173,9 +175,9 @@ func LocalIP() (string, error) { ...@@ -173,9 +175,9 @@ func LocalIP() (string, error) {
func CachePath() (string, error) { func CachePath() (string, error) {
candidates := make([]string, 0, 2) candidates := make([]string, 0, 2)
if runtime.GOOS != "windows" { 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) path := firstWritablePath(candidates)
if path == "" { if path == "" {
return "", errors.New("No writable temporary directory found") return "", errors.New("No writable temporary directory found")
......
...@@ -44,21 +44,21 @@ func Initialize(configuration *server.Configuration) error { ...@@ -44,21 +44,21 @@ func Initialize(configuration *server.Configuration) error {
if err != nil { if err != nil {
return err 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 { if err := conf.IrmaConfiguration.DownloadDefaultSchemes(); err != nil {
return err return err
} }
} else { } else {
if err = conf.IrmaConfiguration.ParseFolder(); err != nil { return errors.New("no schemes found in irma_configuration folder " + conf.IrmaConfiguration.Path)
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 { if conf.IssuerPrivateKeys == nil {
conf.IssuerPrivateKeys = make(map[irma.IssuerIdentifier]*gabi.PrivateKey) conf.IssuerPrivateKeys = make(map[irma.IssuerIdentifier]*gabi.PrivateKey)
} }
......
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