Skip to content

Commit 3f87240

Browse files
committed
Add XML configuration guidance to authorizeRequests deprecation warning
When using XML configuration with <intercept-url>, Spring Security internally registers a FilterSecurityInterceptor, which triggers the authorizeRequests deprecation warning. However, the warning message previously provided no actionable guidance for XML users. This commit adds a note to the deprecation warning indicating that XML users should add use-authorization-manager="true" to their <http> element to migrate to the modern authorization model. Closes gh-17259
1 parent fe2e52f commit 3f87240

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

config/src/main/java/org/springframework/security/config/http/DefaultFilterChainValidator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ private void checkAuthorizationFilters(List<SecurityFilterChain> chains) {
126126
}
127127
if (filterSecurityInterceptor != null) {
128128
this.logger.warn(
129-
"Usage of authorizeRequests is deprecated. Please use authorizeHttpRequests in the configuration");
129+
"Usage of authorizeRequests is deprecated. Please use authorizeHttpRequests in the configuration. "
130+
+ "If you are using XML configuration with <intercept-url>, "
131+
+ "add use-authorization-manager=\"true\" to your <http> element.");
130132
}
131133
authorizationFilter = null;
132134
filterSecurityInterceptor = null;

config/src/test/java/org/springframework/security/config/http/DefaultFilterChainValidatorTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@ public void validateCheckLoginPageAllowsAnonymous() {
132132
+ "access to the configured login page. (Simulated access was rejected)");
133133
}
134134

135+
@Test
136+
void validateWhenOnlyFilterSecurityInterceptorThenWarnWithXmlGuidance() {
137+
this.validator.validate(this.chain);
138+
verify(this.logger).warn(
139+
"Usage of authorizeRequests is deprecated. Please use authorizeHttpRequests in the configuration. "
140+
+ "If you are using XML configuration with <intercept-url>, "
141+
+ "add use-authorization-manager=\"true\" to your <http> element.");
142+
}
143+
135144
// SEC-1957
136145
@Test
137146
public void validateCustomMetadataSource() {

0 commit comments

Comments
 (0)