Skip to content

Commit 596449d

Browse files
committed
Polish
Issue gh-14149
1 parent 1a4de49 commit 596449d

File tree

2 files changed

+3
-18
lines changed

2 files changed

+3
-18
lines changed

config/src/main/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurer.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -397,7 +397,7 @@ protected IgnoreCsrfProtectionRegistry chainRequestMatchers(List<RequestMatcher>
397397

398398
}
399399

400-
private static class SpaCsrfTokenRequestHandler implements CsrfTokenRequestHandler {
400+
private static final class SpaCsrfTokenRequestHandler implements CsrfTokenRequestHandler {
401401

402402
private final CsrfTokenRequestAttributeHandler plain = new CsrfTokenRequestAttributeHandler();
403403

@@ -409,27 +409,12 @@ private static class SpaCsrfTokenRequestHandler implements CsrfTokenRequestHandl
409409

410410
@Override
411411
public void handle(HttpServletRequest request, HttpServletResponse response, Supplier<CsrfToken> csrfToken) {
412-
/*
413-
* Always use XorCsrfTokenRequestAttributeHandler to provide BREACH protection
414-
* of the CsrfToken when it is rendered in the response body.
415-
*/
416412
this.xor.handle(request, response, csrfToken);
417413
}
418414

419415
@Override
420416
public String resolveCsrfTokenValue(HttpServletRequest request, CsrfToken csrfToken) {
421417
String headerValue = request.getHeader(csrfToken.getHeaderName());
422-
/*
423-
* If the request contains a request header, use
424-
* CsrfTokenRequestAttributeHandler to resolve the CsrfToken. This applies
425-
* when a single-page application includes the header value automatically,
426-
* which was obtained via a cookie containing the raw CsrfToken.
427-
*
428-
* In all other cases (e.g. if the request contains a request parameter), use
429-
* XorCsrfTokenRequestAttributeHandler to resolve the CsrfToken. This applies
430-
* when a server-side rendered form includes the _csrf request parameter as a
431-
* hidden input.
432-
*/
433418
return (StringUtils.hasText(headerValue) ? this.plain : this.xor).resolveCsrfTokenValue(request, csrfToken);
434419
}
435420

config/src/test/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)