Skip to content
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

CSRFHandler improvements #2648

Merged
merged 1 commit into from
Sep 25, 2024
Merged

Conversation

tsegismont
Copy link
Contributor

Firstly, the CSRF token is put in the session (if there is one) as soon as it is generated. By doing so, we make sure the token is persisted and when the session is flushed (when response headers have been sent). Then, the CSRFHandler works not only with a LocalSessionStore, but with any distributed session store.

Secondly, the CSRF cookie is sent to the client in response to GET requests whenever the value is no longer synchronized with the value stored in the session (if there is one). This prevents users from being "trapped" if a new token has been generated but never makes to the client (e.g. if the response body never makes it to the client).

See #2599

@tsegismont tsegismont requested a review from vietj September 12, 2024 14:53
@tsegismont tsegismont force-pushed the csrf-improvements branch 2 times, most recently from 18b9415 to 3b91489 Compare September 16, 2024 12:29
Firstly, the CSRF token is put in the session (if there is one) as soon as it is generated. By doing so, we make sure the token is persisted and when the session is flushed (when response headers have been sent).
Then, the CSRFHandler works not only with a LocalSessionStore, but with any distributed session store.

Secondly, the CSRF cookie is sent to the client in response to GET requests whenever the value is no longer synchronized with the value stored in the session (if there is one). This prevents users from being "trapped" if a new token has been generated but never makes to the client (e.g. if the response body never makes it to the client).

Signed-off-by: Thomas Segismont <[email protected]>
@tsegismont tsegismont removed the request for review from vietj September 25, 2024 09:26
@tsegismont tsegismont merged commit 8a25d0b into vert-x3:master Sep 25, 2024
6 of 7 checks passed
@tsegismont tsegismont deleted the csrf-improvements branch September 25, 2024 09:28
tsegismont added a commit that referenced this pull request Sep 25, 2024
Firstly, the CSRF token is put in the session (if there is one) as soon as it is generated. By doing so, we make sure the token is persisted and when the session is flushed (when response headers have been sent).
Then, the CSRFHandler works not only with a LocalSessionStore, but with any distributed session store.

Secondly, the CSRF cookie is sent to the client in response to GET requests whenever the value is no longer synchronized with the value stored in the session (if there is one). This prevents users from being "trapped" if a new token has been generated but never makes to the client (e.g. if the response body never makes it to the client).

Signed-off-by: Thomas Segismont <[email protected]>
code-brazier pushed a commit to code-brazier/vertx-web that referenced this pull request Dec 23, 2024
Firstly, the CSRF token is put in the session (if there is one) as soon as it is generated. By doing so, we make sure the token is persisted and when the session is flushed (when response headers have been sent).
Then, the CSRFHandler works not only with a LocalSessionStore, but with any distributed session store.

Secondly, the CSRF cookie is sent to the client in response to GET requests whenever the value is no longer synchronized with the value stored in the session (if there is one). This prevents users from being "trapped" if a new token has been generated but never makes to the client (e.g. if the response body never makes it to the client).

Signed-off-by: Thomas Segismont <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant