Skip to content

Commit a32a431

Browse files
Upgrade Spring Boot 4/JDK 25 - build authentication-service, build person-service, build user-service
1 parent 3f9130f commit a32a431

File tree

7 files changed

+57
-47
lines changed

7 files changed

+57
-47
lines changed

authentication-service/pom.xml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@
2121
</properties>
2222

2323
<dependencies>
24-
<dependency>
25-
<groupId>org.springframework.integration</groupId>
26-
<artifactId>spring-integration-ip</artifactId>
27-
</dependency>
28-
29-
<dependency>
30-
<groupId>org.springframework.boot</groupId>
31-
<artifactId>spring-boot-starter-integration</artifactId>
32-
</dependency>
33-
3424
<dependency>
3525
<groupId>net.logstash.logback</groupId>
3626
<artifactId>logstash-logback-encoder</artifactId>
@@ -89,7 +79,12 @@
8979

9080
<dependency>
9181
<groupId>org.springframework.boot</groupId>
92-
<artifactId>spring-boot-starter-oauth2-authorization-server</artifactId>
82+
<artifactId>spring-boot-starter-security-oauth2-authorization-server</artifactId>
83+
</dependency>
84+
85+
<dependency>
86+
<groupId>org.springframework.security</groupId>
87+
<artifactId>spring-security-oauth2-authorization-server</artifactId>
9388
</dependency>
9489

9590
<dependency>
@@ -261,6 +256,10 @@
261256
<artifactId>mongodb</artifactId>
262257
<scope>test</scope>
263258
</dependency>
259+
<dependency>
260+
<groupId>org.springframework.boot</groupId>
261+
<artifactId>spring-boot-security-oauth2-client</artifactId>
262+
</dependency>
264263
</dependencies>
265264

266265
<build>

authentication-service/src/main/java/com/microservice/authentication/AuthenticationRuntimeHints.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
import org.springframework.aot.hint.RuntimeHints;
2424
import org.springframework.aot.hint.RuntimeHintsRegistrar;
25-
import org.springframework.integration.ip.tcp.connection.TcpNetClientConnectionFactory;
2625

2726
public class AuthenticationRuntimeHints implements RuntimeHintsRegistrar {
2827

authentication-service/src/main/java/com/microservice/authentication/AuthenticationServiceApplication.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@
5959
import org.springframework.data.mongodb.core.MongoTemplate;
6060
import org.springframework.data.mongodb.core.mapping.event.ValidatingMongoEventListener;
6161
import org.springframework.http.HttpStatus;
62-
import org.springframework.integration.dsl.IntegrationFlow;
63-
import org.springframework.integration.dsl.Transformers;
64-
import org.springframework.integration.ip.dsl.Tcp;
65-
import org.springframework.integration.ip.tcp.serializer.TcpCodecs;
6662
import org.springframework.scheduling.annotation.EnableAsync;
6763
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
6864
import org.springframework.security.crypto.password.PasswordEncoder;
@@ -97,27 +93,6 @@ public static void main(String[] args) {
9793
SpringApplication.run(AuthenticationServiceApplication.class, args);
9894
}
9995

100-
@Bean
101-
public IntegrationFlow client() {
102-
return f -> f.handle(Tcp.outboundGateway(Tcp.netClient("localhost", 1234)
103-
.deserializer(TcpCodecs.lengthHeader1())
104-
.serializer(TcpCodecs.lengthHeader1())))
105-
.transform(Transformers.objectToString())
106-
.handle(msg -> log.info("Transforming message: {}", msg));
107-
}
108-
109-
/*@Bean
110-
public IntegrationFlow server() {
111-
return IntegrationFlow.from(Tcp.inboundAdapter(Tcp.netClient("localhost",8081)
112-
.deserializer(TcpCodecs.lengthHeader1()))
113-
// .errorChannel("tcpIn.errorChannel")
114-
.id("tcpIn"))
115-
.transform(Transformers.objectToString())
116-
.handle(msg -> log.info("Transforming message: {}", msg))
117-
// .channel("tcpInbound")
118-
.get();
119-
}*/
120-
12196
@Bean
12297
@ConditionalOnMissingBean
12398
public SessionRepository defaultSessionRepository() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.microservice.authentication.config;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
7+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
8+
import org.springframework.boot.security.oauth2.client.autoconfigure.ConditionalOnOAuth2ClientRegistrationProperties;
9+
import org.springframework.boot.security.oauth2.client.autoconfigure.OAuth2ClientProperties;
10+
import org.springframework.boot.security.oauth2.client.autoconfigure.OAuth2ClientPropertiesMapper;
11+
import org.springframework.context.annotation.Bean;
12+
import org.springframework.context.annotation.Configuration;
13+
import org.springframework.security.oauth2.client.registration.ClientRegistration;
14+
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
15+
import org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository;
16+
17+
@Configuration(
18+
proxyBeanMethods = false
19+
)
20+
@ConditionalOnOAuth2ClientRegistrationProperties
21+
@EnableConfigurationProperties({OAuth2ClientProperties.class})
22+
@ConditionalOnMissingBean({ClientRegistrationRepository.class})
23+
public class ClientRegistrationRepositoryConfiguration {
24+
@Bean
25+
InMemoryClientRegistrationRepository clientRegistrationRepository(OAuth2ClientProperties properties) {
26+
List<ClientRegistration> registrations = new ArrayList<>((new OAuth2ClientPropertiesMapper(properties)).asClientRegistrations().values());
27+
return new InMemoryClientRegistrationRepository(registrations);
28+
}
29+
}

authentication-service/src/main/java/com/microservice/authentication/config/SpringSecurityConfiguration.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import org.springframework.beans.factory.annotation.Value;
2121
import org.springframework.boot.context.properties.ConfigurationProperties;
22-
import org.springframework.boot.security.oauth2.server.authorization.autoconfigure.servlet.OAuth2AuthorizationServerAutoConfiguration;
2322
import org.springframework.boot.web.error.ErrorAttributeOptions;
2423
import org.springframework.boot.webmvc.error.DefaultErrorAttributes;
2524
import org.springframework.context.annotation.Bean;
@@ -42,6 +41,8 @@
4241
import org.springframework.security.config.annotation.web.configurers.ott.OneTimeTokenLoginConfigurer;
4342
import org.springframework.security.config.http.SessionCreationPolicy;
4443
import org.springframework.security.core.userdetails.UserDetailsService;
44+
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
45+
import org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository;
4546
import org.springframework.security.oauth2.core.AuthorizationGrantType;
4647
import org.springframework.security.oauth2.core.ClientAuthenticationMethod;
4748
import org.springframework.security.oauth2.core.OAuth2AccessToken;
@@ -148,7 +149,7 @@ public SecurityFilterChain oauth2ServerSecurityFilterChain(HttpSecurity http) th
148149
.oauth2ResourceServer(resourceServer -> resourceServer.jwt(withDefaults()))
149150
.build();
150151

151-
//OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(http);
152+
// OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(http);
152153
/*http.with(OAuth2AuthorizationServerConfigurer.authorizationServer(), Customizer.withDefaults());
153154
154155
http.getConfigurer(OAuth2AuthorizationServerConfigurer.class)

docker/docker-compose.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ services:
6868
- 8080:8080
6969
volumes:
7070
- ./docker-entrypoint.sh:/docker-entrypoint.sh
71-
- ./opentelemetry-javaagent.jar:/opt/opentelemetry-javaagent.jar
71+
# - ./opentelemetry-javaagent.jar:/opt/opentelemetry-javaagent.jar
7272
# - /Users/rodrigo/Downloads/ssl/old/www.spendingbetter.com.jks:/www.spendingbetter.com.jks
7373
# command: sh ./docker-entrypoint.sh service-discovery:8500
7474
networks:
@@ -373,19 +373,23 @@ services:
373373
# Using docker local jib maven
374374
#image: authentication-service:latest #fielcapao/microservices-design-patterns-authentication-service
375375
# Using docker raspberry pi image
376-
#image: fielcapao/microservices-design-patterns-authentication-service
376+
# image: fielcapao/microservices-design-patterns-authentication-service
377377
container_name: authentication-api
378378
environment:
379379
- SPRING_PROFILES_ACTIVE=consul,dev,auth
380380
- SPRING_DATA_REDIS_HOST=redisdb
381381
- CONSUL_URL=service-discovery:8500
382+
- SPRING_CLOUD_CONSUL_HOST=service-discovery
382383
- SERVER_PORT=9999
383384
- SPRING_DATA_MONGODB_URI=mongodb://mongodb-datasource:27017/docker
385+
- SPRING_MONGODB_HOST=mongodb-datasource
386+
- SPRING_MONGODB_DATABASE=docker
384387
- SPRING_DATA_MONGODB_DATABASE=docker
385388
- SPRING_MAIN_ALLOW_CIRCULAR_REFERENCES=true
386389
- COM_MICROSERVICE_AUTHENTICATION_REDIS_ENABLED=true
387390
- DEBUG=true
388391
- MANAGEMENT_ENDPOINTS_WEB_CORS_ALLOW_CREDENTIALS=false
392+
- MANAGEMENT_HEALTH_MAIL_ENABLED=false
389393
# - LOGGING_LEVEL_ORG_SPRINGFRAMEWORK=trace
390394
# - LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_WEB=trace
391395
- LOGGING_LEVEL_COM_MICROSERVICE=debug
@@ -397,18 +401,20 @@ services:
397401
- SPRING_CONFIG_IMPORT=consul:service-discovery:8500
398402
- SPRING_CLOUD_CONSUL_DISCOVERY_PREFER_IP_ADDRESS=true
399403
- JAVA_OPTS=--enable-preview -Xss256K -Xms1M -XX:+UseSerialGC -Djava.compiler=none -XX:ReservedCodeCacheSize=2496k -XX:MaxDirectMemorySize=1M
400-
- JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
404+
# - JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
401405
# - MANAGEMENT_HEALTH_REDIS_ENABLED=false
402406
# - COM_MICROSERVICE_AUTHENTICATION_JWT_KEY_VALUE=
403407
# - COM_MICROSERVICE_AUTHENTICATION_JWT_KEY_STORE=file:/www.spendingbetter.com.jks
404408
# - COM_MICROSERVICE_AUTHENTICATION_JWT_KEY_STORE_PASSWORD=${CERT_PASSWORD}
405409
# - COM_MICROSERVICE_AUTHENTICATION_JWT_KEY_ALIAS=spendingbetter
406410
- SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK_SET_URI=http://localhost:9999/.well-known/jwks.json
411+
- OTEL_SDK_DISABLED=true
412+
- SPRING_AUTOCONFIGURE_EXCLUDE_0=org.springdoc.core.configuration.SpringDocConfiguration
407413
# - LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_SECURITY=debug
408-
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318
409-
- OTEL_JAVAAGENT_DEBUG=false
410-
- OTEL_PROPAGATORS=tracecontext,b3
411-
- OTEL_PROPAGATORS_ENABLED=true
414+
# - OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318
415+
# - OTEL_JAVAAGENT_DEBUG=false
416+
# - OTEL_PROPAGATORS=tracecontext,b3
417+
# - OTEL_PROPAGATORS_ENABLED=true
412418
depends_on:
413419
- service-discovery
414420
- mongodb-datasource
@@ -417,6 +423,7 @@ services:
417423
- redisdb
418424
# - jaeger
419425
- service-discovery-load-configuration
426+
- otel-collector
420427
ports:
421428
- 9999:9999
422429
- 5005:5005

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<docker.image.from.fabric8>openjdk:25-jdk</docker.image.from.fabric8>
2929
<code-coverage>0.8</code-coverage>
3030
<dockerfile-maven-plugin.version>1.3.4</dockerfile-maven-plugin.version>
31-
<docker.env.JAVA_OPTS>--enable-preview -javaagent:/opt/opentelemetry-javaagent.jar -Xmx512m -Dfile.encoding=UTF-8 -XX:+UseG1GC -verbose:gc -XX:+PrintGCDetails -Xloggc:/var/log/gc.log -Djava.security.egd=file:/dev/./urandom</docker.env.JAVA_OPTS>
31+
<docker.env.JAVA_OPTS>--enable-preview -Xmx512m -Dfile.encoding=UTF-8 -XX:+UseG1GC -verbose:gc -XX:+PrintGCDetails -Xloggc:/var/log/gc.log -Djava.security.egd=file:/dev/./urandom</docker.env.JAVA_OPTS>
3232
<repackage.classifier/>
3333
</properties>
3434

0 commit comments

Comments
 (0)