diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurer.java index 2ed4d28dc7..47f906fd2a 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurer.java @@ -97,7 +97,7 @@ public final class CsrfConfigurer> extends Abst * @return the {@link CsrfConfigurer} for further customizations */ public CsrfConfigurer requireCsrfProtectionMatcher(RequestMatcher requireCsrfProtectionMatcher) { - Assert.notNull(csrfTokenRepository, "requireCsrfProtectionMatcher cannot be null"); + Assert.notNull(requireCsrfProtectionMatcher, "requireCsrfProtectionMatcher cannot be null"); this.requireCsrfProtectionMatcher = requireCsrfProtectionMatcher; return this; } diff --git a/config/src/test/groovy/org/springframework/security/config/annotation/web/configurers/CsrfConfigurerTests.groovy b/config/src/test/groovy/org/springframework/security/config/annotation/web/configurers/CsrfConfigurerTests.groovy index ca64d469dd..8f95a220aa 100644 --- a/config/src/test/groovy/org/springframework/security/config/annotation/web/configurers/CsrfConfigurerTests.groovy +++ b/config/src/test/groovy/org/springframework/security/config/annotation/web/configurers/CsrfConfigurerTests.groovy @@ -464,6 +464,13 @@ class CsrfConfigurerTests extends BaseSpringSpec { } } + def 'SEC-2749: requireCsrfProtectionMatcher null'() { + when: + new CsrfConfigurer<>().requireCsrfProtectionMatcher(null) + then: + thrown(IllegalArgumentException) + } + def clearCsrfToken() { request.removeAllParameters() }