Skip to content

Commit

Permalink
🔒 Update Default Filter Chain Ordering for Spring Security
Browse files Browse the repository at this point in the history
  • Loading branch information
haynescd committed Nov 1, 2024
1 parent 8c934c4 commit 8e4d61a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.lang.Nullable;
import org.springframework.security.authentication.AuthenticationManager;
Expand All @@ -30,6 +32,7 @@ public class ApiSecurityConfig {
// see: "Creating and Customizing Filter Chains" @ https://spring.io/guides/topicals/spring-security-architecture

@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public SecurityFilterChain securityFilterChain(HttpSecurity http, @Nullable DataAccessTokenService tokenService) throws Exception {
http.csrf(AbstractHttpConfigurer::disable)
// This filter chain only grabs requests to the '/api' path.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class OAuth2SecurityConfig {
private static final String LOGIN_URL = "/login";

@Bean
@Order(1)
public SecurityFilterChain filterChain(HttpSecurity http, ClientRegistrationRepository clientRegistrationRepository) throws Exception {
http.csrf(AbstractHttpConfigurer::disable)
.cors(Customizer.withDefaults())
Expand Down

0 comments on commit 8e4d61a

Please sign in to comment.