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

feat: add sameSite parameter to unset_cookie #2140

Merged
merged 8 commits into from
Jan 18, 2023

Conversation

TigreModerata
Copy link
Contributor

@TigreModerata TigreModerata commented Jan 16, 2023

Summary of Changes

Added samesite parameter to unset_cookies, defaulting to 'Lax'.
Tests: added a test case to test_unset_cookies and to on_get in CookieUnset
Docs: added explanation of new parameter to cookies.rst

Related Issues

Fixes #2124

Pull Request Checklist

This is just a reminder about the most common mistakes. Please make sure that you tick all appropriate boxes. But please read our contribution guide at least once; it will save you a few review cycles!

If an item doesn't apply to your pull request, check it anyway to make it apparent that there's nothing to do.

  • Applied changes to both WSGI and ASGI code paths and interfaces (where applicable).
  • Added tests for changed code.
  • Prefixed code comments with GitHub nick and an appropriate prefix.
  • Coding style is consistent with the rest of the framework.
  • Updated documentation for changed code.
    • Added docstrings for any new classes, functions, or modules.
    • Updated docstrings for any modifications to existing code.
    • Updated both WSGI and ASGI docs (where applicable).
    • Added references to new classes, functions, or modules to the relevant RST file under docs/.
    • Updated all relevant supporting documentation files under docs/.
    • A copyright notice is included at the top of any new modules (using your own name or the name of your organization).
    • Changed/added classes/methods/functions have appropriate versionadded, versionchanged, or deprecated directives.
  • Changes (and possible deprecations) have towncrier news fragments under docs/_newsfragments/, with the file name format {issue_number}.{fragment_type}.rst. (Run towncrier --draft to ensure it renders correctly.)

If you have any questions to any of the points above, just submit and ask! This checklist is here to help you, not to deter you from contributing!

PR template inspired by the attrs project.

@vytas7 vytas7 changed the title #2124 enhancement feat: add sameSite parameter to unset_cookie Jan 16, 2023
Copy link
Member

@vytas7 vytas7 left a comment

Choose a reason for hiding this comment

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

That looks like a great start, thanks! 💯

In order to merge this, we also need a towncrier news fragment describing the new feature; the file ought to be named docs/_newsfragments/2124.newandimproved.rst.

I would also like to see a couple more combinations of samesite covered in the unit tests in conjunction with set_/unset_cookie(...).

Furthermore, it seems that some CI gates are failing, such as pep8 & blue. Tip: you can simply install blue (pip install -U blue) into your environment and reformat the code (blue .).


When unsetting a cookie, :py:meth:`~falcon.Response.unset_cookie`,
the default `SameSite` setting of the unset cookie is ``'Lax'``, but can be changed
by setting the 'samsite' kwarg.
Copy link
Member

Choose a reason for hiding this comment

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

Typo 'samsite' (sic) ➡️ 'samesite'.

@codecov
Copy link

codecov bot commented Jan 16, 2023

Codecov Report

Merging #2140 (c5a0b88) into master (16d4710) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master     #2140   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           62        62           
  Lines         6789      6789           
  Branches      1095      1095           
=========================================
  Hits          6789      6789           
Impacted Files Coverage Δ
falcon/response.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@TigreModerata
Copy link
Contributor Author

Excellent, thanks for the comments, I'll push an update asap!

@TigreModerata TigreModerata requested review from vytas7 and removed request for kgriffs and CaselIT January 17, 2023 16:43
Copy link
Member

@vytas7 vytas7 left a comment

Choose a reason for hiding this comment

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

You need to revert docs/changes/4.0.0.rst -- we don't want to render that file yet, we'll probably do that at some time around the first beta release.

@TigreModerata
Copy link
Contributor Author

You need to revert docs/changes/4.0.0.rst -- we don't want to render that file yet, we'll probably do that at some time around the first beta release.

Done

CaselIT
CaselIT previously approved these changes Jan 18, 2023
Copy link
Member

@CaselIT CaselIT left a comment

Choose a reason for hiding this comment

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

thanks for the contribution

@CaselIT CaselIT requested a review from vytas7 January 18, 2023 20:07
Copy link
Member

@vytas7 vytas7 left a comment

Choose a reason for hiding this comment

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

Thanks! 👍
(I'll tweak the newsfragment later a bit because we have some others that require more cleanup anyway.)

@vytas7 vytas7 merged commit d2981f6 into falconry:master Jan 18, 2023
@CaselIT
Copy link
Member

CaselIT commented Jan 18, 2023

Thanks! 👍 (I'll tweak the newsfragment later a bit because we have some others that require more cleanup anyway.)

should also add @TigreModerata to the contridutors

@vytas7
Copy link
Member

vytas7 commented Jan 18, 2023

Yes, we run that script from time to time now, particularly before releases 🙂

@CaselIT
Copy link
Member

CaselIT commented Jan 18, 2023

forgot we automated that!

@TigreModerata
Copy link
Contributor Author

Thanks to all - I will try to contribute more in the future, when I know how :)

@vytas7
Copy link
Member

vytas7 commented Jan 18, 2023

Thank you for contributing @TigreModerata!
If you want to take one more issue, let us know 🙂 #1010 might be a good one for new contributors, but you can of course pick whatever you like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request: Add sameSite parameter to unset_cookie
3 participants