JAVA-25157 | minor fixes (#14915)
This commit is contained in:
parent
64377f45a2
commit
03a3587560
|
@ -102,7 +102,7 @@
|
|||
</build>
|
||||
|
||||
<properties>
|
||||
<start-class>com.baeldung.keycloak.SpringBoot</start-class>
|
||||
<start-class>com.baeldung.keycloak.SpringBootKeycloakApp</start-class>
|
||||
<jaxb-runtime.version>4.0.0</jaxb-runtime.version>
|
||||
<wsdl4j.version>1.6.3</wsdl4j.version>
|
||||
<jaxb2-maven-plugin.version>2.5.0</jaxb2-maven-plugin.version>
|
||||
|
|
|
@ -6,11 +6,10 @@ import org.springframework.context.annotation.Bean;
|
|||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@SpringBootApplication
|
||||
|
||||
public class SpringBoot {
|
||||
public class SpringBootKeycloakApp {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringBoot.class, args);
|
||||
SpringApplication.run(SpringBootKeycloakApp.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
|
@ -4,10 +4,9 @@ import org.junit.Test;
|
|||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import com.baeldung.keycloak.SpringBoot;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest(classes = { SpringBoot.class })
|
||||
@SpringBootTest(classes = { SpringBootKeycloakApp.class })
|
||||
public class KeycloakContextIntegrationTest {
|
||||
|
||||
@Test
|
||||
|
|
|
@ -3,10 +3,11 @@ package com.baeldung.swaggerkeycloak;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.security.config.Customizer;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configurers.oauth2.server.resource.OAuth2ResourceServerConfigurer;
|
||||
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
|
||||
import org.springframework.security.core.session.SessionRegistryImpl;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
import org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy;
|
||||
|
@ -24,16 +25,19 @@ public class GlobalSecurityConfig {
|
|||
|
||||
@Bean
|
||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
http.csrf()
|
||||
.disable()
|
||||
.authorizeRequests()
|
||||
.requestMatchers(HttpMethod.OPTIONS)
|
||||
|
||||
http.csrf(AbstractHttpConfigurer::disable)
|
||||
.authorizeHttpRequests((requests) -> requests.requestMatchers(HttpMethod.OPTIONS)
|
||||
.permitAll()
|
||||
.requestMatchers("/api/**")
|
||||
.authenticated()
|
||||
.anyRequest()
|
||||
.permitAll();
|
||||
http.oauth2ResourceServer(OAuth2ResourceServerConfigurer::jwt);
|
||||
.permitAll());
|
||||
|
||||
http.oauth2ResourceServer((oauth2) -> oauth2
|
||||
.jwt(Customizer.withDefaults())
|
||||
);
|
||||
|
||||
return http.build();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue