spring-projects / spring-projects/spring-security

CsrfRequestDataValueProcessor uses a different attribute name then the rest of the CSRF parts.

Open
#12,443 5 comments 0 reactions 1 assignee View on GitHub

@sjohnr is already working on this.

Since Dec 21, 2022.

in: web status: feedback-provided type: enhancement
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

When working with Spring Webflux and CSRF protection additional steps are needed to expose the CSRF Token to the frontend. The reference guide mentions an @ControllerAdvice (which will only work for controllers) if you also have RouterFunction materials you need to add an additional HandlerFilterFunction so it copies the thing around.

When combining different ways of configuring endpoiints, it all adds up with additional cruft to have in place for a proper working of the CSRF tokens. Wouldn't it be easier for the CsrfRequestDataValueProcessor to utilize the same name CsrfToken.class.getName() to obtain the actual CsrfToken and expose it as hidden fields?

I wonder why the discrepancy with the regular CSRF protection and the additional (complexer) setup. As the servlet variant of the CsrfRequestDataValueProcessor does actually use the "proper" attribute name.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.