JAVA-25489 Upgrade to Spring Boot 3
This commit is contained in:
parent
ed2f3234e6
commit
92a8290fc8
|
@ -11,9 +11,10 @@
|
||||||
<description>This is a simple application demonstrating integration between Keycloak and Spring Boot.</description>
|
<description>This is a simple application demonstrating integration between Keycloak and Spring Boot.</description>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung.spring-boot-modules</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>spring-boot-modules</artifactId>
|
<artifactId>parent-boot-3</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath>../../parent-boot-3</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -105,7 +106,7 @@
|
||||||
<start-class>com.baeldung.keycloak.SpringBoot</start-class>
|
<start-class>com.baeldung.keycloak.SpringBoot</start-class>
|
||||||
<jaxb-runtime.version>4.0.0</jaxb-runtime.version>
|
<jaxb-runtime.version>4.0.0</jaxb-runtime.version>
|
||||||
<wsdl4j.version>1.6.3</wsdl4j.version>
|
<wsdl4j.version>1.6.3</wsdl4j.version>
|
||||||
<jaxb2-maven-plugin.version>2.5.0</jaxb2-maven-plugin.version>
|
<jaxb2-maven-plugin.version>3.1.0</jaxb2-maven-plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -1,9 +1,9 @@
|
||||||
package com.baeldung.keycloak;
|
package com.baeldung.keycloak;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import jakarta.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class Customer {
|
public class Customer {
|
||||||
|
|
|
@ -10,8 +10,8 @@ import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class KeycloakLogoutHandler implements LogoutHandler {
|
public class KeycloakLogoutHandler implements LogoutHandler {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import org.springframework.security.core.session.SessionRegistryImpl;
|
||||||
import org.springframework.security.web.SecurityFilterChain;
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
import org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy;
|
import org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy;
|
||||||
import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy;
|
import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy;
|
||||||
|
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebSecurity
|
@EnableWebSecurity
|
||||||
|
@ -32,7 +33,7 @@ class SecurityConfig {
|
||||||
@Bean
|
@Bean
|
||||||
public SecurityFilterChain clientFilterChain(HttpSecurity http) throws Exception {
|
public SecurityFilterChain clientFilterChain(HttpSecurity http) throws Exception {
|
||||||
http.authorizeRequests()
|
http.authorizeRequests()
|
||||||
.antMatchers("/")
|
.requestMatchers(new AntPathRequestMatcher("/"))
|
||||||
.permitAll()
|
.permitAll()
|
||||||
.anyRequest()
|
.anyRequest()
|
||||||
.authenticated();
|
.authenticated();
|
||||||
|
@ -48,7 +49,7 @@ class SecurityConfig {
|
||||||
@Bean
|
@Bean
|
||||||
public SecurityFilterChain resourceServerFilterChain(HttpSecurity http) throws Exception {
|
public SecurityFilterChain resourceServerFilterChain(HttpSecurity http) throws Exception {
|
||||||
http.authorizeRequests()
|
http.authorizeRequests()
|
||||||
.antMatchers("/customers*")
|
.requestMatchers(new AntPathRequestMatcher("/customers*"))
|
||||||
.hasRole("USER")
|
.hasRole("USER")
|
||||||
.anyRequest()
|
.anyRequest()
|
||||||
.authenticated();
|
.authenticated();
|
||||||
|
|
|
@ -8,7 +8,7 @@ import java.security.Principal;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class WebController {
|
public class WebController {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
|
||||||
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
|
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
|
||||||
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;
|
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;
|
||||||
|
|
||||||
import javax.annotation.security.RolesAllowed;
|
import jakarta.annotation.security.RolesAllowed;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Endpoint
|
@Endpoint
|
||||||
|
|
|
@ -10,7 +10,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
import org.springframework.boot.web.server.LocalServerPort;
|
import org.springframework.boot.test.web.server.LocalServerPort;
|
||||||
import org.springframework.http.HttpEntity;
|
import org.springframework.http.HttpEntity;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
|
|
Loading…
Reference in New Issue