Forward port of #13868

Comment From: marcusdacoregio

Closed via https://github.com/spring-projects/spring-security/commit/c6841d83ebaa51c022ecee979c6aec774ad52fd5