https://github.com/volfpeter/flask-session-decoder
Zero-dependency Flask session decoder
https://github.com/volfpeter/flask-session-decoder
cookie decoder flask flask-login python3 session
Last synced: 8 months ago
JSON representation
Zero-dependency Flask session decoder
- Host: GitHub
- URL: https://github.com/volfpeter/flask-session-decoder
- Owner: volfpeter
- License: mit
- Created: 2022-12-16T09:43:58.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-19T09:14:33.000Z (over 3 years ago)
- Last Synced: 2025-02-05T12:25:03.495Z (over 1 year ago)
- Topics: cookie, decoder, flask, flask-login, python3, session
- Language: Python
- Homepage:
- Size: 13.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# flask-session-decoder
Zero-dependency Flask session decoder.
This is a small library without any dependencies. It works with close to default Flask session security configurations, but obviously does not provide the full cookie decoding and verification capabilities of `flask` / `werkzeug` / `itsdangerous`. If your project already depends on these libraries, use the official tooling instead.
## Installation and Usage
You can install the library from PyPI with `pip install flask-session-decoder`.
Once installed, you can import and instantiate the decoder like this:
```python
from flask_session_decoder import FlaskSessionDecoder
decoder = FlaskSessionDecoder(secret_key="the-secret-key-of-the-flask-app-that-created-the-cookie")
```
`FlaskSessionDecoder` provides three methods for cookie verification and loading:
- `decoder.load(cookie)` returns the (by default verified) decoded string representation of the cookie.
- `decoder.json(cookie)` returns the (by default verified) decoded cookie as a `dict`.
- `verify(cookie)` returns whether the cookie signature is valid, without actually loading the value.
## Development
Use `black` for code formatting and `mypy` for static code analysis.
## License - MIT
The library is open-sourced under the conditions of the MIT [license](https://choosealicense.com/licenses/mit/).