Skip to content

Commit

Permalink
gateway csrf return to spring 5.8 default
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhir committed Nov 16, 2023
1 parent 45763a0 commit df42ca9
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.springframework.security.web.server.authentication.RedirectServerAuthenticationSuccessHandler;
import org.springframework.security.web.server.authentication.logout.HttpStatusReturningServerLogoutSuccessHandler;
import org.springframework.security.web.server.csrf.CookieServerCsrfTokenRepository;
import org.springframework.security.web.server.csrf.ServerCsrfTokenRequestAttributeHandler;
import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatchers;
import reactor.core.publisher.Mono;

Expand Down Expand Up @@ -59,6 +60,12 @@ public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http)
})
.cors(corsSpec -> {})
.csrf(csrfSpec -> {
/*
* Default config before spring security 6.0.
* Is vulnerable to BREACH attack.
* https://docs.spring.io/spring-security/reference/reactive/exploits/csrf.html#webflux-csrf-configure-request-handler
*/
csrfSpec.csrfTokenRequestHandler(new ServerCsrfTokenRequestAttributeHandler());
/*
* The necessary subscription for csrf token attachment to {@link ServerHttpResponse}
* is done in class {@link CsrfTokenAppendingHelperFilter}.
Expand Down

0 comments on commit df42ca9

Please sign in to comment.