spring-projects / spring-projects/spring-data-rest
Adding Spring Data REST prevents CsrfTokenArgumentResolver [DATAREST-656]
@odrotbohm is already working on this.
Since Dec 31, 2020.
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
Rob Winch opened DATAREST-656 and commented
In a standard Spring MVC controller adding Spring Data REST causes Spring Security's to be ignored CsrfTokenArgumentResolver. The problem is that ProxyingHandlerMethodArgumentResolver is registered first which will intercept any interface.
The issue can be worked around by using the following:
@Configuration
@Order(Ordered.HIGHEST_PRECEDENCE )
public class MvcConfig extends WebMvcConfigurerAdapter {
@Override
public void addArgumentResolvers(
List<HandlerMethodArgumentResolver> argumentResolvers) {
argumentResolvers.add(new CsrfTokenArgumentResolver());
}
}
You can see a sample at https://github.com/rwinch/spring-state-securing-restful-apis/tree/DATAREST-656 by running SpringSessionApplicationTests.
Reference URL: https://github.com/rwinch/spring-state-securing-restful-apis/tree/DATAREST-656
Issue Links:
- DATAREST-657 Unable to resolve PersistentEntityResourceAssembler
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.