|
|
|
@ -34,7 +34,7 @@ import org.springframework.core.annotation.Order; |
|
|
|
import org.springframework.http.MediaType; |
|
|
|
import org.springframework.http.MediaType; |
|
|
|
import org.springframework.security.config.Customizer; |
|
|
|
import org.springframework.security.config.Customizer; |
|
|
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
|
|
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
|
|
|
import org.springframework.security.config.annotation.web.configurers.oauth2.server.resource.OAuth2ResourceServerConfigurer; |
|
|
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; |
|
|
|
import org.springframework.security.core.userdetails.User; |
|
|
|
import org.springframework.security.core.userdetails.User; |
|
|
|
import org.springframework.security.core.userdetails.UserDetails; |
|
|
|
import org.springframework.security.core.userdetails.UserDetails; |
|
|
|
import org.springframework.security.core.userdetails.UserDetailsService; |
|
|
|
import org.springframework.security.core.userdetails.UserDetailsService; |
|
|
|
@ -60,6 +60,7 @@ import org.springframework.security.web.util.matcher.MediaTypeRequestMatcher; |
|
|
|
import org.springframework.security.web.util.matcher.RequestMatcher; |
|
|
|
import org.springframework.security.web.util.matcher.RequestMatcher; |
|
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
|
|
|
|
@EnableWebSecurity |
|
|
|
public class JwtUserInfoMapperSecurityConfig { |
|
|
|
public class JwtUserInfoMapperSecurityConfig { |
|
|
|
|
|
|
|
|
|
|
|
@Bean // <1>
|
|
|
|
@Bean // <1>
|
|
|
|
@ -90,7 +91,9 @@ public class JwtUserInfoMapperSecurityConfig { |
|
|
|
.anyRequest().authenticated() |
|
|
|
.anyRequest().authenticated() |
|
|
|
) |
|
|
|
) |
|
|
|
.csrf(csrf -> csrf.ignoringRequestMatchers(endpointsMatcher)) |
|
|
|
.csrf(csrf -> csrf.ignoringRequestMatchers(endpointsMatcher)) |
|
|
|
.oauth2ResourceServer(OAuth2ResourceServerConfigurer::jwt) // <4>
|
|
|
|
.oauth2ResourceServer(resourceServer -> resourceServer |
|
|
|
|
|
|
|
.jwt(Customizer.withDefaults()) // <4>
|
|
|
|
|
|
|
|
) |
|
|
|
.exceptionHandling((exceptions) -> exceptions |
|
|
|
.exceptionHandling((exceptions) -> exceptions |
|
|
|
.defaultAuthenticationEntryPointFor( |
|
|
|
.defaultAuthenticationEntryPointFor( |
|
|
|
new LoginUrlAuthenticationEntryPoint("/login"), |
|
|
|
new LoginUrlAuthenticationEntryPoint("/login"), |
|
|
|
|