From cc33538f11d9292465bc2fdf0275233b1ff7df9e Mon Sep 17 00:00:00 2001 From: arekkas <aeneas@ory.am> Date: Wed, 1 Aug 2018 13:08:27 +0200 Subject: [PATCH] cmd: Improve refresh subroutines Signed-off-by: arekkas <aeneas@ory.am> --- cmd/helper_server.go | 16 ++++++++++------ cmd/serve_proxy.go | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/cmd/helper_server.go b/cmd/helper_server.go index 85cb1b8423..5ae9cea7aa 100644 --- a/cmd/helper_server.go +++ b/cmd/helper_server.go @@ -50,10 +50,12 @@ func getHydraSDK() hydra.SDK { return sdk } -func refreshRules(m rule.Refresher) { - duration, _ := time.ParseDuration(viper.GetString("RULES_REFRESH_INTERVAL")) +func refreshRules(m rule.Refresher, duration time.Duration) { if duration == 0 { - duration = time.Second * 30 + duration, _ = time.ParseDuration(viper.GetString("RULES_REFRESH_INTERVAL")) + if duration == 0 { + duration = time.Second * 30 + } } var fails int @@ -74,10 +76,12 @@ func refreshRules(m rule.Refresher) { } } -func refreshKeys(k rsakey.Manager) { - duration, _ := time.ParseDuration(viper.GetString("CREDENTIALS_ISSUER_ID_TOKEN_JWK_REFRESH_INTERVAL")) +func refreshKeys(k rsakey.Manager, duration time.Duration) { if duration == 0 { - duration = time.Minute * 5 + duration, _ = time.ParseDuration(viper.GetString("CREDENTIALS_ISSUER_ID_TOKEN_JWK_REFRESH_INTERVAL")) + if duration == 0 { + duration = time.Minute * 5 + } } var fails int diff --git a/cmd/serve_proxy.go b/cmd/serve_proxy.go index 58c8ccb0c6..ae44539e83 100644 --- a/cmd/serve_proxy.go +++ b/cmd/serve_proxy.go @@ -159,8 +159,8 @@ OTHER CONTROLS logger.WithError(err).Fatalln("Unable to initialize the ID Token signing algorithm") } - go refreshRules(matcher) - go refreshKeys(keyManager) + go refreshRules(matcher, 0) + go refreshKeys(keyManager, 0) var authorizers = []proxy.Authorizer{ proxy.NewAuthorizerAllow(),