Skip to content

Commit

Permalink
cmd: Improve refresh subroutines
Browse files Browse the repository at this point in the history
Signed-off-by: arekkas <[email protected]>
  • Loading branch information
arekkas authored and arekkas committed Aug 1, 2018
1 parent 08204e8 commit cc33538
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
16 changes: 10 additions & 6 deletions cmd/helper_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cmd/serve_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit cc33538

Please sign in to comment.