diff options
author | Michal Duda <michal.duda@sonarsource.com> | 2020-04-08 19:38:02 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-04-14 20:04:04 +0000 |
commit | d662d0c0269e1a12da0c3ecdb8f9d33b765ccdcc (patch) | |
tree | 7ec6d738cc8516bf42f42552a64f1cdbb0307a37 /server/sonar-webserver-auth | |
parent | ab6328a769fbe531464fc9dd77cc64efc72ba390 (diff) | |
download | sonarqube-d662d0c0269e1a12da0c3ecdb8f9d33b765ccdcc.tar.gz sonarqube-d662d0c0269e1a12da0c3ecdb8f9d33b765ccdcc.zip |
SONAR-13272 fix issue with setting some properties through env variables
Diffstat (limited to 'server/sonar-webserver-auth')
2 files changed, 9 insertions, 8 deletions
diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/JwtHttpHandler.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/JwtHttpHandler.java index 9c9eb212450..a46245a0ab0 100644 --- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/JwtHttpHandler.java +++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/JwtHttpHandler.java @@ -40,13 +40,12 @@ import static com.google.common.base.Preconditions.checkArgument; import static java.util.Objects.requireNonNull; import static org.apache.commons.lang.StringUtils.isEmpty; import static org.apache.commons.lang.time.DateUtils.addSeconds; +import static org.sonar.process.ProcessProperties.Property.WEB_SESSION_TIMEOUT_IN_MIN; import static org.sonar.server.authentication.Cookies.findCookie; import static org.sonar.server.authentication.Cookies.newCookieBuilder; @ServerSide public class JwtHttpHandler { - - private static final String SESSION_TIMEOUT_IN_MINUTES_PROPERTY = "sonar.web.sessionTimeoutInMinutes"; private static final int SESSION_TIMEOUT_DEFAULT_VALUE_IN_MINUTES = 3 * 24 * 60; private static final int MAX_SESSION_TIMEOUT_IN_MINUTES = 3 * 30 * 24 * 60; @@ -175,10 +174,11 @@ public class JwtHttpHandler { } private static int getSessionTimeoutInSeconds(Configuration config) { - int minutes = config.getInt(SESSION_TIMEOUT_IN_MINUTES_PROPERTY).orElse(SESSION_TIMEOUT_DEFAULT_VALUE_IN_MINUTES); - checkArgument(minutes > 0, "Property %s must be strictly positive. Got %s", SESSION_TIMEOUT_IN_MINUTES_PROPERTY, minutes); - checkArgument(minutes <= MAX_SESSION_TIMEOUT_IN_MINUTES, "Property %s must not be greater than 3 months (%s minutes). Got %s minutes", - SESSION_TIMEOUT_IN_MINUTES_PROPERTY, MAX_SESSION_TIMEOUT_IN_MINUTES, minutes); + int minutes = config.getInt(WEB_SESSION_TIMEOUT_IN_MIN.getKey()).orElse(SESSION_TIMEOUT_DEFAULT_VALUE_IN_MINUTES); + checkArgument(minutes > 0, "Property %s must be strictly positive. Got %s", WEB_SESSION_TIMEOUT_IN_MIN.getKey(), minutes); + checkArgument(minutes <= MAX_SESSION_TIMEOUT_IN_MINUTES, + "Property %s must not be greater than 3 months (%s minutes). Got %s minutes", WEB_SESSION_TIMEOUT_IN_MIN.getKey(), + MAX_SESSION_TIMEOUT_IN_MINUTES, minutes); return minutes * 60; } diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/SystemPasscodeImpl.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/SystemPasscodeImpl.java index 43c4551e4e5..8511de7a7ac 100644 --- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/SystemPasscodeImpl.java +++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/SystemPasscodeImpl.java @@ -27,11 +27,12 @@ import org.sonar.api.server.ServerSide; import org.sonar.api.server.ws.Request; import org.sonar.api.utils.log.Loggers; +import static org.sonar.process.ProcessProperties.Property.WEB_SYSTEM_PASS_CODE; + @ServerSide public class SystemPasscodeImpl implements SystemPasscode, Startable { public static final String PASSCODE_HTTP_HEADER = "X-Sonar-Passcode"; - public static final String PASSCODE_CONF_PROPERTY = "sonar.web.systemPasscode"; private final Configuration configuration; private String configuredPasscode; @@ -52,7 +53,7 @@ public class SystemPasscodeImpl implements SystemPasscode, Startable { @Override public void start() { - Optional<String> passcodeOpt = configuration.get(PASSCODE_CONF_PROPERTY) + Optional<String> passcodeOpt = configuration.get(WEB_SYSTEM_PASS_CODE.getKey()) // if present, result is never empty string .map(StringUtils::trimToNull); |