diff --git a/jhipster/demo.adoc b/jhipster/demo.adoc index 206a7a3..43f9c5c 100644 --- a/jhipster/demo.adoc +++ b/jhipster/demo.adoc @@ -4,7 +4,7 @@ = Java Microservices with Spring Cloud Config and JHipster -The brackets at the end of each step indicate the alias's or IntelliJ Live Templates to use. You can find the template definitions at https://github.com/mraible/idea-live-templates[mraible/idea-live-templates]. +If you'd like to see a video version of this demo, you can https://www.youtube.com/watch?v=ez7HMO60kE8[watch it on YouTube]. == Create Microservices with JHipster @@ -123,6 +123,8 @@ deployment { +. Convert gateway to be a PWA + . Create Docker images for Spring Boot apps mvn -Pprod verify com.google.cloud.tools:jib-maven-plugin:dockerBuild @@ -164,6 +166,8 @@ deployment { . Demo JHipster Registry and gateway log in with Okta +. Show Lighthouse Score + . Finito! 🤓 == Learn More! diff --git a/jhipster/gateway/src/main/webapp/content/images/jhipster_family_member_0.svg b/jhipster/gateway/src/main/webapp/content/images/jhipster_family_member_0.svg index 1f9ab52..fd59561 100755 --- a/jhipster/gateway/src/main/webapp/content/images/jhipster_family_member_0.svg +++ b/jhipster/gateway/src/main/webapp/content/images/jhipster_family_member_0.svg @@ -1,198 +1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/jhipster/gateway/src/main/webapp/content/images/jhipster_family_member_1.svg b/jhipster/gateway/src/main/webapp/content/images/jhipster_family_member_1.svg index 7a118f3..508aa1e 100755 --- a/jhipster/gateway/src/main/webapp/content/images/jhipster_family_member_1.svg +++ b/jhipster/gateway/src/main/webapp/content/images/jhipster_family_member_1.svg @@ -1,9387 +1 @@ - - - -image/svg+xml \ No newline at end of file + \ No newline at end of file diff --git a/jhipster/gateway/src/main/webapp/content/images/jhipster_family_member_2.svg b/jhipster/gateway/src/main/webapp/content/images/jhipster_family_member_2.svg index 1747933..69f3f43 100755 --- a/jhipster/gateway/src/main/webapp/content/images/jhipster_family_member_2.svg +++ b/jhipster/gateway/src/main/webapp/content/images/jhipster_family_member_2.svg @@ -1,841 +1 @@ - - - -image/svg+xml \ No newline at end of file + \ No newline at end of file diff --git a/jhipster/gateway/src/main/webapp/content/images/jhipster_family_member_3.svg b/jhipster/gateway/src/main/webapp/content/images/jhipster_family_member_3.svg index 6b9e056..fbbe8f7 100755 --- a/jhipster/gateway/src/main/webapp/content/images/jhipster_family_member_3.svg +++ b/jhipster/gateway/src/main/webapp/content/images/jhipster_family_member_3.svg @@ -1,308 +1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/jhipster/gateway/src/main/webapp/swagger-ui/dist/images/throbber.gif b/jhipster/gateway/src/main/webapp/swagger-ui/dist/images/throbber.gif index 0639388..0a55cf0 100644 Binary files a/jhipster/gateway/src/main/webapp/swagger-ui/dist/images/throbber.gif and b/jhipster/gateway/src/main/webapp/swagger-ui/dist/images/throbber.gif differ diff --git a/spring-boot+cloud/api-gateway/pom.xml b/spring-boot+cloud/api-gateway/pom.xml index 371a56a..00e2c39 100755 --- a/spring-boot+cloud/api-gateway/pom.xml +++ b/spring-boot+cloud/api-gateway/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 2.1.5.RELEASE + 2.2.5.RELEASE com.example @@ -16,7 +16,7 @@ 1.8 - Greenwich.SR1 + Hoxton.SR3 @@ -47,7 +47,7 @@ com.okta.spring okta-spring-boot-starter - 1.2.0 + 1.4.0 org.projectlombok diff --git a/spring-boot+cloud/api-gateway/src/main/java/com/example/apigateway/ApiGatewayApplication.java b/spring-boot+cloud/api-gateway/src/main/java/com/example/apigateway/ApiGatewayApplication.java index 900914a..d5bb6ef 100755 --- a/spring-boot+cloud/api-gateway/src/main/java/com/example/apigateway/ApiGatewayApplication.java +++ b/spring-boot+cloud/api-gateway/src/main/java/com/example/apigateway/ApiGatewayApplication.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.Ordered; -import org.springframework.hateoas.Resources; +import org.springframework.hateoas.CollectionModel; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.oauth2.client.OAuth2AuthorizedClientService; @@ -92,7 +92,7 @@ interface CarClient { @GetMapping("/cars") @CrossOrigin - Resources readCars(); + CollectionModel readCars(); } @RestController diff --git a/spring-boot+cloud/api-gateway/src/main/resources/application.properties b/spring-boot+cloud/api-gateway/src/main/resources/application.properties index 7256e35..45e869e 100755 --- a/spring-boot+cloud/api-gateway/src/main/resources/application.properties +++ b/spring-boot+cloud/api-gateway/src/main/resources/application.properties @@ -1,7 +1,7 @@ spring.application.name=api-gateway -okta.oauth2.issuer=https://dev-737523.oktapreview.com/oauth2/default -okta.oauth2.client-id=0oafx05pu2pxhjgkC0h7 -okta.oauth2.client-secret=ozxBeuk7nE-oLhkUvINe1cxR3LITquTp7Jt2NvX7 +okta.oauth2.issuer=https://dev-133320.okta.com/oauth2/default +okta.oauth2.client-id=0oa35aqn81ftCrz53357 +okta.oauth2.client-secret=lchv-e8ZLN3si7v84tVq-W4OT1l7kzkE5irBvDhs feign.hystrix.enabled=true hystrix.shareSecurityContext=true diff --git a/spring-boot+cloud/car-service/pom.xml b/spring-boot+cloud/car-service/pom.xml index 1ba35c4..90d627f 100755 --- a/spring-boot+cloud/car-service/pom.xml +++ b/spring-boot+cloud/car-service/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 2.1.5.RELEASE + 2.2.5.RELEASE com.example @@ -16,7 +16,7 @@ 1.8 - Greenwich.SR1 + Hoxton.SR3 @@ -43,7 +43,7 @@ com.okta.spring okta-spring-boot-starter - 1.2.0 + 1.4.0 org.springframework.boot diff --git a/spring-boot+cloud/car-service/src/main/resources/application.properties b/spring-boot+cloud/car-service/src/main/resources/application.properties index e7d4fa3..7f79ddb 100755 --- a/spring-boot+cloud/car-service/src/main/resources/application.properties +++ b/spring-boot+cloud/car-service/src/main/resources/application.properties @@ -1,5 +1,5 @@ server.port=8090 spring.application.name=car-service -okta.oauth2.issuer=https://dev-737523.oktapreview.com/oauth2/default -okta.oauth2.client-id=0oafx05pu2pxhjgkC0h7 -okta.oauth2.client-secret=ozxBeuk7nE-oLhkUvINe1cxR3LITquTp7Jt2NvX7 +okta.oauth2.issuer=https://dev-133320.okta.com/oauth2/default +okta.oauth2.client-id=0oa35aqn81ftCrz53357 +okta.oauth2.client-secret=lchv-e8ZLN3si7v84tVq-W4OT1l7kzkE5irBvDhs diff --git a/spring-boot+cloud/demo.adoc b/spring-boot+cloud/demo.adoc index 8707a07..10ba73a 100644 --- a/spring-boot+cloud/demo.adoc +++ b/spring-boot+cloud/demo.adoc @@ -32,13 +32,6 @@ The brackets at the end of each step indicate the alias's or IntelliJ Live Templ sdk install java 11.0.2-open sdk default java 11.0.2-open -. Add JAXB to `discovery-service` so it works with Java 11 - - - org.glassfish.jaxb - jaxb-runtime - - . Add `@EnableEurekaServer` and properties to set port and turn off discovery server.port=8761 @@ -79,7 +72,7 @@ The brackets at the end of each step indicate the alias's or IntelliJ Live Templ com.okta.spring okta-spring-boot-starter - 1.2.1 + 1.4.0 . Create a web app on Okta, use `http://localhost:8080/login/oauth2/code/okta` for redirect URI diff --git a/spring-boot+cloud/discovery-service/pom.xml b/spring-boot+cloud/discovery-service/pom.xml index b7dfd6e..8a0c7f5 100755 --- a/spring-boot+cloud/discovery-service/pom.xml +++ b/spring-boot+cloud/discovery-service/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 2.1.5.RELEASE + 2.2.5.RELEASE com.example @@ -16,7 +16,7 @@ 11 - Greenwich.SR1 + Hoxton.SR3 @@ -24,10 +24,6 @@ org.springframework.cloud spring-cloud-starter-netflix-eureka-server - - org.glassfish.jaxb - jaxb-runtime - org.springframework.boot spring-boot-starter-test diff --git a/spring-cloud-gateway/api-gateway/src/main/java/com/example/apigateway/ApiGatewayApplication.java b/spring-cloud-gateway/api-gateway/src/main/java/com/example/apigateway/ApiGatewayApplication.java index 5ee2d2d..1060f86 100755 --- a/spring-cloud-gateway/api-gateway/src/main/java/com/example/apigateway/ApiGatewayApplication.java +++ b/spring-cloud-gateway/api-gateway/src/main/java/com/example/apigateway/ApiGatewayApplication.java @@ -9,6 +9,8 @@ import org.springframework.cloud.netflix.eureka.EnableEurekaClient; import org.springframework.cloud.security.oauth2.gateway.TokenRelayGatewayFilterFactory; import org.springframework.context.annotation.Bean; +import org.springframework.security.oauth2.client.OAuth2AuthorizedClient; +import org.springframework.security.oauth2.client.annotation.RegisteredOAuth2AuthorizedClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.reactive.function.client.WebClient; @@ -59,8 +61,9 @@ public FaveCarsController(WebClient.Builder carClient) { } @GetMapping("/fave-cars") - public Flux faveCars() { + public Flux faveCars(@RegisteredOAuth2AuthorizedClient("okta") OAuth2AuthorizedClient authorizedClient) { return carClient.build().get().uri("lb://car-service/cars") + .header("Authorization", "Bearer " + authorizedClient.getAccessToken().getTokenValue()) .retrieve().bodyToFlux(Car.class) .filter(this::isFavorite); } diff --git a/spring-cloud-gateway/api-gateway/src/main/java/com/example/apigateway/SecurityConfiguration.java b/spring-cloud-gateway/api-gateway/src/main/java/com/example/apigateway/SecurityConfiguration.java index 56c37b6..adb18c1 100644 --- a/spring-cloud-gateway/api-gateway/src/main/java/com/example/apigateway/SecurityConfiguration.java +++ b/spring-cloud-gateway/api-gateway/src/main/java/com/example/apigateway/SecurityConfiguration.java @@ -6,7 +6,7 @@ import org.springframework.security.config.web.server.ServerHttpSecurity; import org.springframework.security.web.server.SecurityWebFilterChain; import org.springframework.web.cors.CorsConfiguration; -import org.springframework.web.cors.reactive.CorsWebFilter; +import org.springframework.web.cors.reactive.CorsConfigurationSource; import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource; import java.util.List; @@ -31,7 +31,7 @@ public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) { } @Bean - CorsWebFilter corsWebFilter() { + CorsConfigurationSource corsConfigurationSource() { CorsConfiguration corsConfig = new CorsConfiguration(); corsConfig.setAllowedOrigins(List.of("*")); corsConfig.setMaxAge(3600L); @@ -40,7 +40,6 @@ CorsWebFilter corsWebFilter() { UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); source.registerCorsConfiguration("/**", corsConfig); - - return new CorsWebFilter(source); + return source; } }