Consistent environment values and url references (#1677)

* organizing environment variables

* Update application-webgoat.properties

* Update pom.xml

* test without ssl

* fix docker base image and default env entries

* seperate server.address from webgoat.host and webwolf.host

* change base image and enable endpoint logging for docker as well

* change README

* change README

* make integration test able to verify against alternative host names

* use dynamic ports and remove system println
This commit is contained in:
René Zubcevic
2023-11-27 14:35:49 +01:00
committed by GitHub
parent 62db86246e
commit 826887cc83
11 changed files with 90 additions and 85 deletions

View File

@ -17,6 +17,11 @@ public class StartupMessage {
private String address;
private String contextPath;
private String applicationName;
private static boolean useSSL =
Boolean.valueOf(System.getenv().getOrDefault("WEBGOAT_SSLENABLED", "true"));
@EventListener
void onStartup(ApplicationReadyEvent event) {
@ -24,9 +29,24 @@ public class StartupMessage {
address = event.getApplicationContext().getEnvironment().getProperty("server.address");
contextPath =
event.getApplicationContext().getEnvironment().getProperty("server.servlet.context-path");
if (StringUtils.hasText(port)
&& !StringUtils.hasText(System.getProperty("running.in.docker"))) {
log.warn("Please browse to http://{}:{}{} to get started...", address, port, contextPath);
applicationName =
event.getApplicationContext().getEnvironment().getProperty("spring.application.name");
if (StringUtils.hasText(applicationName)) {
if (applicationName.equals("WebGoat")) {
log.warn(
"Please browse to "
+ (useSSL ? "https://" : "http://")
+ "{}:{}{} to start using WebGoat...",
event.getApplicationContext().getEnvironment().getProperty("webgoat.host"),
port,
contextPath);
} else {
log.warn(
"Please browse to http://{}:{}{} to start using WebWolf...",
event.getApplicationContext().getEnvironment().getProperty("webwolf.host"),
port,
contextPath);
}
}
}