Skip to content

Commit c2f7dd8

Browse files
committed
Revert default for CRSF enabled to false
Fixes gh-12267
1 parent 4524921 commit c2f7dd8

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public class SecurityProperties implements SecurityPrerequisite {
7575
/**
7676
* Enable Cross Site Request Forgery support.
7777
*/
78-
private boolean enableCsrf = true;
78+
private boolean enableCsrf = false;
7979

8080
private Basic basic = new Basic();
8181

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/SecurityPropertiesTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ public void testRole() {
123123
}
124124

125125
@Test
126-
public void testCSrf() {
127-
assertThat(this.security.isEnableCsrf()).isEqualTo(true);
128-
this.binder.bind(new MutablePropertyValues(
129-
Collections.singletonMap("security.enable-csrf", false)));
126+
public void testCsrf() {
130127
assertThat(this.security.isEnableCsrf()).isEqualTo(false);
128+
this.binder.bind(new MutablePropertyValues(
129+
Collections.singletonMap("security.enable-csrf", true)));
130+
assertThat(this.security.isEnableCsrf()).isEqualTo(true);
131131
}
132132

133133
}

spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ content into your application; rather pick only the properties that you need.
447447
security.basic.enabled=true # Enable basic authentication.
448448
security.basic.path=/** # Comma-separated list of paths to secure.
449449
security.basic.realm=Spring # HTTP basic realm name.
450-
security.enable-csrf=true # Enable Cross Site Request Forgery support.
450+
security.enable-csrf=false # Enable Cross Site Request Forgery support.
451451
security.filter-order=0 # Security filter chain order.
452452
security.filter-dispatcher-types=ASYNC, FORWARD, INCLUDE, REQUEST # Security filter chain dispatcher types.
453453
security.headers.cache=true # Enable cache control HTTP headers.

spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2536,8 +2536,9 @@ The basic features you get out of the box in a web application are:
25362536
* HTTP Basic security for all other endpoints.
25372537
* Security events published to Spring's `ApplicationEventPublisher` (successful and
25382538
unsuccessful authentication and access denied).
2539-
* Common low-level features (HSTS, XSS, CSRF, caching) provided by Spring Security are
2539+
* Common low-level features (HSTS, XSS, caching) provided by Spring Security are
25402540
on by default.
2541+
* Cross Site Request Forgery (CSRF) checks are disabled by default.
25412542

25422543
All of the above can be switched on and off or modified using external properties
25432544
(`+security.*+`). To override the access rules without changing any other auto-configured
@@ -2790,6 +2791,7 @@ If the Actuator is also in use, you will find:
27902791
* Security events are transformed into `AuditEvent` instances and published to the
27912792
`AuditEventRepository`.
27922793
* The default user will have the `ACTUATOR` role as well as the `USER` role.
2794+
* Cross Site Request Forgery (CSRF) checks are disabled for actuator endpoints.
27932795

27942796
The Actuator security features can be modified using external properties
27952797
(`+management.security.*+`). To override the application access rules

0 commit comments

Comments
 (0)