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

Clear __csrf cookie after logout #927

Merged
merged 1 commit into from
Jul 20, 2023
Merged

Clear __csrf cookie after logout #927

merged 1 commit into from
Jul 20, 2023

Conversation

matthew-white
Copy link
Member

After a session is created, Backend returns two cookies: __Host-session and __csrf. The cookies expire at the same time as the session, so if a session expires on its own, the cookies will expire as well and be cleared. If the user logs out the session before it expires, then the __Host-session cookie is cleared — but the __csrf cookie is not. I don't think that's a huge deal, but I think it's cleaner to clear both cookies together, which is what this PR does.

What has been done to verify that this works as intended?

Updated tests.

Why is this the best possible solution? Were any other approaches considered?

The change is pretty small.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

This change isn't really user-facing. It's more about cleaning up after logout. I think the risk of regression is low.

Does this change require updates to the API documentation? If so, please update docs/api.md as part of this PR.

I don't think changes are needed. We discourage the use of cookie auth in the API docs, and we don't document the __csrf cookie at all.

Before submitting this PR, please make sure you have:

  • run make test-full and confirmed all checks still pass OR confirm CircleCI build passes
  • verified that any code from external sources are properly credited in comments or that everything is internally sourced

Copy link
Contributor

@alxndrsn alxndrsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's surprising that the cookies are "unset" by setting them to the string null, rather than an empty string. But with the given expiry, the client should delete them immediately anyway 👍

@matthew-white matthew-white self-assigned this Jul 20, 2023
Base automatically changed from logout-current to master July 20, 2023 04:04
@matthew-white matthew-white merged commit 5c27f00 into master Jul 20, 2023
1 check passed
@matthew-white matthew-white deleted the clear-csrf branch July 20, 2023 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ done
Development

Successfully merging this pull request may close these issues.

2 participants