This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Slf4j | |
@SpringBootApplication | |
public class Application implements ApplicationRunner, Runnable, ExitCodeGenerator { | |
private final SomeAppLogic someAppLogic; | |
private final Thread mainThread; | |
private int exitCode = 0; | |
public static void main(String[] args) { | |
System.exit(SpringApplication.exit(SpringApplication.run(Application.class, args))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Override profile when running locally | |
bootRun { | |
environment SPRING_PROFILES_ACTIVE: environment.SPRING_PROFILES_ACTIVE ?: "local" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#access open to all pages | |
spring.profiles.active=local | |
#require password for /admin | |
spring.profiles.active=password | |
spring.security.user.name=<user> | |
spring.security.user.password=<password> | |
#require Okta login for /admin | |
#in Okta dashboard, the web app login redirect URI must be set to (can be localhost if needed): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
class WebSecurityConfig { | |
@Profile("local") | |
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true) | |
@EnableWebSecurity | |
public static class SecurityDisabledConfig extends WebSecurityConfigurerAdapter { | |
@Override | |
protected void configure(HttpSecurity http) throws Exception { | |
// allow all requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring.security.oauth2.client.registration.okta.client-id=<client> | |
spring.security.oauth2.client.registration.okta.client-secret=<client-secret> | |
spring.security.oauth2.client.provider.okta.issuer-uri=https://<your-company>.okta.com/oauth2/default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true) | |
@EnableWebSecurity | |
public class SecurityOktaConfig extends WebSecurityConfigurerAdapter { | |
@Override | |
protected void configure(HttpSecurity http) throws Exception { | |
http.authorizeRequests() | |
// require authenticated access to all resources | |
.anyRequest().authenticated() | |
// set logout URL | |
.and().logout().logoutSuccessUrl("/") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static final String PULSAR = "pulsar://pulsar:6650"; | |
new DockerComposeContainer(new File("docker-compose/consumer.docker-compose.yml")) | |
.withEnv("PULSAR_NETWORK", pulsarNetworkName) | |
.withEnv("PULSAR", PULSAR) | |
.waitingFor("main-consumer_1", Wait.forLogMessage(".*Consumer started.*", 1)) | |
.start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
some-service: | |
image: openjdk:8-jre-alpine | |
networks: | |
- pulsar-net | |
networks: | |
pulsar-net: | |
external: | |
name: $PULSAR_NETWORK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ContainerState cs = (ContainerState)pulsarEnv.getContainerByServiceName("pulsar_1").get(); | |
Map<String, ContainerNetwork> cns = cs.getCurrentContainerInfo().getNetworkSettings().getNetworks(); | |
// We know that the compose file defines exactly one network, so get its name | |
String pulsarNetworkName = cns.keySet().iterator().next(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.testcontainers.containers.DockerComposeContainer | |
final int PULSAR_ADMIN_PORT = 8080; | |
final int PULSAR_DATA_PORT = 6650; | |
new DockerComposeContainer("pulsar", new File("docker-compose/pulsar.docker-compose.yml")) | |
.withExposedService("pulsar_1", PULSAR_ADMIN_PORT, | |
Wait.forHttp("/metrics").forStatusCode(200).forPort(PULSAR_ADMIN_PORT)) | |
.withExposedService("pulsar_1", PULSAR_DATA_PORT, Wait.forListeningPort()) | |
.start(); |
NewerOlder