Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/c00kiemon5ter/cookies_samesite_compat
WSGI Middleware to preserve compatibility regarding cookies with the SameSite attribute
https://github.com/c00kiemon5ter/cookies_samesite_compat
cookies python3 samesite samesite-cookies wsgi wsgi-middleware
Last synced: 14 days ago
JSON representation
WSGI Middleware to preserve compatibility regarding cookies with the SameSite attribute
- Host: GitHub
- URL: https://github.com/c00kiemon5ter/cookies_samesite_compat
- Owner: c00kiemon5ter
- License: apache-2.0
- Created: 2020-02-26T22:00:42.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-02-27T09:52:36.000Z (over 4 years ago)
- Last Synced: 2024-10-28T17:36:43.551Z (23 days ago)
- Topics: cookies, python3, samesite, samesite-cookies, wsgi, wsgi-middleware
- Language: Python
- Homepage: https://pypi.org/project/cookies-samesite-compat/
- Size: 7.81 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Cookies SameSite compatibility WSGI Middleware
This is a WSGI Middleware that given a configuration dictionary it will look
for the `cookies_samesite_compat` field that should hold a list of two-element
tuples that define two cookie names. The first name is the primary cookie name
and the second is the fallback cookie name. The primary cookie should be set by
the application with all needed attributes set, including the `SameSite`
attribute.On creating the response, the fallback cookie is created based on the primary
cookie, but with the its own name and without the `SameSite` attributes. On
processing a request, if the primary cookie is not there, the fallback cookie
is looked up and used to create the primary cookie, even if the SameSite
attribute will not be set, so that the appication can only care about one
cookie name.### Usage
```python
from cookies_samesite_compat import CookiesSameSiteCompatMiddlewareconfig = get_config()
response = CookiesSameSiteCompatMiddleware(
WsgiApplication(config), config
)
return response
```