Users shared now between WebGoat and WebWolf by starting HSQLDB
as standalone database
This commit is contained in:
@ -4,12 +4,11 @@ ARG webgoat_version=8.0-SNAPSHOT
|
||||
|
||||
RUN \
|
||||
apt-get update && apt-get install && \
|
||||
useradd --home-dir /home/webgoat --create-home -U webgoat && \
|
||||
cd /home/webgoat/; mkdir -p .webgoat
|
||||
useradd --home-dir /home/webgoat --create-home -U webgoat
|
||||
|
||||
USER webgoat
|
||||
RUN cd /home/webgoat/; mkdir -p .webgoat-${webgoat_version}
|
||||
COPY target/webgoat-server-${webgoat_version}.jar /home/webgoat/webgoat.jar
|
||||
|
||||
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/home/webgoat/webgoat.jar", "--server.address=0.0.0.0"]
|
||||
|
||||
EXPOSE 8080
|
@ -0,0 +1,51 @@
|
||||
package org.owasp.webgoat;
|
||||
|
||||
import org.hsqldb.server.Server;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
|
||||
/**
|
||||
* Rationale for this class: when the HSQLDB is started with jdbc:file:// it is only accessible from within the same
|
||||
* JVM. This can only be done if you start a standalone HSQLDB. We need both WebWolf and WebGoat to use the same database
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnProperty(prefix = "webgoat.start", name = "hsqldb", havingValue = "true")
|
||||
public class HSQLDBDatabaseConfig {
|
||||
|
||||
@Value("${hsqldb.port:9001}")
|
||||
private int hsqldbPort;
|
||||
|
||||
@Bean(initMethod = "start", destroyMethod = "stop")
|
||||
public Server hsqlStandalone(@Value("${webgoat.server.directory}") String directory,
|
||||
@Value("${hsqldb.silent:true}") boolean silent,
|
||||
@Value("${hsqldb.trace:false}") boolean trace) {
|
||||
|
||||
Server server = new Server();
|
||||
server.setDatabaseName(0, "webgoat");
|
||||
server.setDatabasePath(0, directory + "/data/webgoat");
|
||||
server.setDaemon(true);
|
||||
server.setTrace(trace);
|
||||
server.setSilent(silent);
|
||||
server.setPort(hsqldbPort);
|
||||
return server;
|
||||
}
|
||||
|
||||
@Primary
|
||||
@Bean
|
||||
@DependsOn("hsqlStandalone")
|
||||
public DataSource dataSource(@Value("${spring.datasource.driver-class-name}") String driverClass,
|
||||
@Value("${spring.datasource.url}") String url) {
|
||||
return DataSourceBuilder.create()
|
||||
.driverClassName(driverClass)
|
||||
.url(url)
|
||||
.build();
|
||||
}
|
||||
}
|
@ -37,7 +37,4 @@ public class StartWebGoat {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(WebGoat.class, args);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user