Skip to content
Snippets Groups Projects

Resolve "Improve security by enabling and enforcing more linting rules"

2 files
+ 13
7
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -118,7 +118,7 @@ func InitializeConfig() error {
FilesystemPathToStores = "stores"
}
JWTDuration, err = getDurationFromViper(jwtDurationKey, time.Hour)
JWTDuration, err = getDurationFromViper(jwtDurationKey, "h")
if err != nil {
JWTDuration = defaultJWTDuration
}
@@ -186,14 +186,15 @@ func setLogLevel() {
}
}
func getDurationFromViper(viperKey string, unit time.Duration) (time.Duration, error) {
duration := viper.GetDuration(viperKey)
func getDurationFromViper(viperKey, unit string) (time.Duration, error) {
durationString := viper.GetString(viperKey)
if duration > 0 {
return duration * unit, nil
duration, err := time.ParseDuration(durationString + unit)
if err != nil {
return 0, err
}
return 0, viper.ConfigParseError{}
return duration, nil
}
func loadAMQPConfig() {
Loading