-
Notifications
You must be signed in to change notification settings - Fork 6k
Add an option to set the SameSite policy in the CookieCsrfTokenRepository #12086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Milestone
Comments
As an additional comment, |
I created a PR with a possible fix for this issue. Please, feel free to review it to see if it is good enough. Any comment will be greatly appreciated. |
kumo829
added a commit
to kumo829/spring-security-fork
that referenced
this issue
Nov 18, 2022
…enRepository - Mark setCookieHttpOnly, setCookieDomain, setCookieMaxAge and setSecure as deprecated. - Add the method setCookieCustomizer which allows to set properties to the ResponseCookieBuilder without having to add new setter methods. Closes spring-projectsgh-12086
jzheaux
pushed a commit
that referenced
this issue
Dec 5, 2022
- For CookieCsrfTokenRepositoryTests and CookieServerCsrfTokenRepositoryTests Issue gh-12086
jzheaux
added a commit
that referenced
this issue
Dec 5, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Expected Behavior
The class
org.springframework.security.web.csrf.CookieCsrfTokenRepository
should allow settingset the SameSite policy as an optional parameter; with this, when sending the CSRF token in a cookie instead of a header, no warning or error should be displayed in the browser's console.Current Behavior
With the current implementation of
org.springframework.security.web.csrf.CookieCsrfTokenRepository
used to send the CSRF token in a cookie instead of a header (widely used when working with, for example JWT), some browsers have started to report a warning stating that:This same behavior happens for each response that includes the cookies (potentially every single request other than the login).
Currently, there is o way no set the SameSite policy in the class
org.springframework.security.web.csrf.CookieCsrfTokenRepository
as internally it uses ajakarta.servlet.http.Cookie
which doesn't allows it either.Context
I've started to see the previous message in the browser's console.
I don't know any workaround other than implementing my own version of
org.springframework.security.web.csrf.CookieCsrfTokenRepository
with the option of adding the SameSite policy, but I guess that this "problem" is affecting others the same way that is affecting me.The text was updated successfully, but these errors were encountered: