Включено CSRF в моем приложении Spring MVC с помощью Spring security 3.2.
Мой spring -security.xml
<http>
<intercept-url pattern="/**/verify" requires-channel="https"/>
<intercept-url pattern="/**/login*" requires-channel="http"/>
...
...
<csrf />
</http>
Попытка отключить CSRF для запросов, которые содержат "проверку" в URL-адресе запроса.
MySecurityConfig.java
@Configuration
@EnableWebSecurity
public class MySecurityConfig extends WebSecurityConfigurerAdapter {
private CsrfMatcher csrfRequestMatcher = new CsrfMatcher();
@Override
public void configure(HttpSecurity http) throws Exception {
http.csrf().requireCsrfProtectionMatcher(csrfRequestMatcher);
}
class CsrfMatcher implements RequestMatcher {
@Override
public boolean matches(HttpServletRequest request) {
if (request.getRequestURL().indexOf("verify") != -1)
return false;
else if (request.getRequestURL().indexOf("homePage") != -1)
return false;
return true;
}
}
}
Фильтр Csrf проверяет токен CSRF, который отправляется из "проверки" и исключение Invalid token (403), когда я отправляю запрос на https из http. Как отключить аутентификацию токена csrf в таком сценарии?