mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-03-06 05:19:15 +00:00
Fix Checkstyle for CsrfWebFilter
Issue gh-9337
This commit is contained in:
parent
a1083d9a5c
commit
0201c31deb
@ -131,8 +131,8 @@ public class CsrfWebFilter implements WebFilter {
|
||||
|
||||
private Mono<Void> validateToken(ServerWebExchange exchange) {
|
||||
return this.csrfTokenRepository.loadToken(exchange)
|
||||
.switchIfEmpty(Mono
|
||||
.defer(() -> Mono.error(new CsrfException("An expected CSRF token cannot be found"))))
|
||||
.switchIfEmpty(
|
||||
Mono.defer(() -> Mono.error(new CsrfException("An expected CSRF token cannot be found"))))
|
||||
.filterWhen((expected) -> containsValidCsrfToken(exchange, expected))
|
||||
.switchIfEmpty(Mono.defer(() -> Mono.error(new CsrfException("Invalid CSRF Token")))).then();
|
||||
}
|
||||
|
@ -34,7 +34,6 @@ import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.reactive.function.BodyInserters;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.WebFilterChain;
|
||||
import org.springframework.web.server.WebSession;
|
||||
|
||||
@ -92,7 +91,7 @@ public class CsrfWebFilterTests {
|
||||
StepVerifier.create(result).verifyComplete();
|
||||
assertThat(this.post.getResponse().getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN);
|
||||
StepVerifier.create(this.post.getResponse().getBodyAsString())
|
||||
.assertNext(b -> assertThat(b).contains("An expected CSRF token cannot be found"));
|
||||
.assertNext((body) -> assertThat(body).contains("An expected CSRF token cannot be found"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user