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

0.7.0 #212

Merged
merged 86 commits into from
Mar 18, 2024
Merged

0.7.0 #212

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
b09ec70
Separate defaults, backwards compatible interface extensions
Lxstr Jan 30, 2024
86895b5
Consistent storage expiry
Lxstr Jan 30, 2024
9acee3c
Use TTL on mongodb for expiration
Lxstr Jan 30, 2024
3fa3d5e
Simplify helper function
Lxstr Jan 31, 2024
5381243
Fix reuse of session id on storage miss
Lxstr Feb 2, 2024
d7ed1c6
Remove null session interface, fix incorrect runtime error
Lxstr Feb 2, 2024
7d7d58c
Refactor to reduce repetition, type hints
Lxstr Feb 4, 2024
95da35b
Fix python 3.7 type hint compatibility
Lxstr Feb 4, 2024
cb36bde
SQL cleanup thread or per requests
Lxstr Feb 4, 2024
ec78cb6
Add app command cleanup, abstract methods
Lxstr Feb 7, 2024
48adc49
Remove thread based cleanup, include alchemy rollback
Lxstr Feb 11, 2024
08179e7
Add retry decorator
Lxstr Feb 11, 2024
bbde311
Mongo test fix
Lxstr Feb 12, 2024
c3bed92
Remove SQLAlchemy exception type due to imports
Lxstr Feb 12, 2024
1daee61
Ruff updates
Lxstr Feb 12, 2024
9af1b58
Pin ruff action version
Lxstr Feb 12, 2024
0467483
SQL cleanup thread or per requests (#211)
Lxstr Feb 15, 2024
56be16d
Use vary Cookie
Lxstr Feb 6, 2024
50247bf
Documentation overhaul
Lxstr Feb 13, 2024
fe4a69b
Fix defaults typo
Lxstr Feb 14, 2024
a5dba70
Deprecate use signer
Lxstr Feb 14, 2024
309bda3
Documentation additions
Lxstr Feb 14, 2024
dbf5387
Add docs for SESSION_CLEANUP_N_REQUESTS
Lxstr Feb 15, 2024
c7f8ced
Add msgspec
Lxstr Feb 15, 2024
2261b44
Backward compatibility with pickle
Lxstr Feb 17, 2024
8340149
Overhaul tests
Lxstr Feb 19, 2024
166372d
Add docs for exceptions
Lxstr Feb 19, 2024
ec15a65
Minor updates to docs and example
Lxstr Feb 19, 2024
a8097cc
Fix test.yaml
Lxstr Feb 19, 2024
db3bbb9
Limit retry decorator to SQL
Lxstr Feb 20, 2024
e091c2e
Update docstrings and documentation
Lxstr Feb 20, 2024
fd8fc93
Readme
Lxstr Feb 20, 2024
e67708d
Recommend redis
Lxstr Feb 20, 2024
519f754
Add supported storage to readme, update example
Lxstr Feb 21, 2024
2bc7df1
Refactor structure for maintainability
Lxstr Feb 23, 2024
68e8ed6
Docs cleanup and linting
Lxstr Feb 23, 2024
431debd
Consistent docstrings
Lxstr Feb 23, 2024
c0602e2
Doc tweaks, include pickle warning
Lxstr Feb 24, 2024
304d0ab
Further documentation tweaks
Lxstr Feb 24, 2024
748ad5c
Note about client security
Lxstr Feb 24, 2024
b9d2f0d
Improve msgspec note
Lxstr Feb 25, 2024
bc37d68
Update logo url
Lxstr Feb 25, 2024
2b08537
Clarify msgspec transition
Lxstr Feb 25, 2024
ce854bb
Fix incorrect error
Lxstr Feb 25, 2024
4afc8b3
Update docs requirements
Lxstr Feb 25, 2024
e990b01
Runtime warnings for invalid instance
Lxstr Feb 25, 2024
7d175bf
Fix forgotten alternate decoder
Lxstr Feb 25, 2024
8ce8d3d
Include clients for docs generation
Lxstr Feb 26, 2024
ede231f
Attempt to fix sphinx warnings
Lxstr Feb 26, 2024
80df635
Add regenerate method
Lxstr Feb 27, 2024
5b999f2
Fix session.clear() in non logout situations
Lxstr Feb 27, 2024
d2ce725
Use .lower on session type
Lxstr Feb 27, 2024
9e00891
Specifically create only the session table in SQLAlchemy
Lxstr Feb 29, 2024
f25d9d3
Expect correct client instances
Lxstr Feb 29, 2024
20e5b41
Remove SQLAlchemy keep_existing in favour of check_first
Lxstr Mar 1, 2024
91df6c9
Prep 0.7.0rc1
Lxstr Mar 1, 2024
9537a41
RTD errors
Lxstr Mar 1, 2024
d6a1566
Fix SESSION_ID_LENGTH typo
Lxstr Mar 4, 2024
d30039a
Pass app to all interfaces for flask logging
Lxstr Mar 4, 2024
c957950
Fix bind key for SQLAlchemy
Lxstr Mar 8, 2024
3fac5b7
Prepare 0.7.0rc2
Lxstr Mar 8, 2024
905c53e
Pass app to cachelib
Lxstr Mar 8, 2024
f9cf9d2
Fix type annotation in Python < 3.8
Taragolis Mar 12, 2024
916ee9d
Fix type annotation in Python < 3.8 (#219)
Lxstr Mar 12, 2024
8f217ca
Fix doctsring
Lxstr Mar 14, 2024
d8c2679
Add more detail on regenerate
Lxstr Mar 14, 2024
7a65fb3
Add contributors
Lxstr Mar 14, 2024
3425fcb
Minor docs typo
Lxstr Mar 14, 2024
0871680
Refactor in line with flask save_session
Lxstr Mar 15, 2024
56937a0
Add should_set_storage to save_session
Lxstr Mar 15, 2024
7ab6980
Add vary cookie for accessed session as per flask
Lxstr Mar 16, 2024
aae7f48
Add docs for serializer
Lxstr Mar 17, 2024
226d2ad
Add docker compose for easier devlopment
Lxstr Mar 17, 2024
c9eeb9a
Formatting
Lxstr Mar 17, 2024
d4dda9f
Describe upgrade process for serialization
Lxstr Mar 17, 2024
8508fb9
Update changelog
Lxstr Mar 17, 2024
e274c08
Typo in deprecation warning
Lxstr Mar 17, 2024
9ead9ce
Add tests for vary header
Lxstr Mar 17, 2024
35d25df
Fix testing warnings
Lxstr Mar 17, 2024
22c2d90
Test python versions
Lxstr Mar 18, 2024
bd7e5b0
Drop python 3.7
Lxstr Mar 18, 2024
78bc8c0
Formatting
Lxstr Mar 18, 2024
a46bbbd
Add rye support
Lxstr Mar 18, 2024
6dfd17e
Use common changelog spec
Lxstr Mar 18, 2024
3bc0d7c
Prep release
Lxstr Mar 18, 2024
4bb803c
Fix changelog typos and clarity
Lxstr Mar 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .github/workflows/ruff.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
name: Ruff
on: [push, pull_request]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: chartboost/ruff-action@v1
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: chartboost/ruff-action@v1
with:
version: 0.1.11
args: --select B
31 changes: 18 additions & 13 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
name: Run unittests
on: [push, pull_request]
jobs:
unittests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: supercharge/[email protected]
- uses: niden/actions-memcached@v7
- uses: actions/setup-python@v4
with:
python-version: 'pypy3.9'
- name: Install testing requirements
run: pip3 install -r requirements/pytest.txt
- name: Run tests
run: pytest tests
unittests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, 3.10, 3.11, 3.12]
services:
mongodb:
image: mongo
ports:
- 27017:27017
steps:
- uses: actions/checkout@v4
- uses: supercharge/[email protected]
- uses: niden/actions-memcached@v7
- name: Install testing requirements
run: pip3 install -r requirements/dev.txt
- name: Run tests
run: pytest tests
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@ __pycache__/
/.mypy_cache/
/.tox/
/docs/_build/

docs/.DS_Store
.python-version
.DS_Store
.python-version
requirements.lock
requirements-dev.lock
96 changes: 71 additions & 25 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,67 +1,113 @@
Version 0.6.0-RC1
0.7.0 - 2024-03-18
------------------

Unreleased
Changed
~~~~~~~~
- Access session interfaces via subfolder, for example ``flask_session.redis.RedisSessionInterface`` (`2bc7df <https://github.com/pallets-eco/flask-session/commit/2bc7df1be7b8929e55cb25f13845caf0503630d8>`_).
- Deprecate ``pickle`` in favor of ``msgspec``, which is configured with ``SESSION_SERIALIZATION_FORMAT`` to choose between ``'json'`` and ``'msgpack'``. All sessions will convert to msgspec upon first interaction with 0.7.0. Pickle is still available to read existing sessions, but will be removed in 1.0.0. (`c7f8ce <https://github.com/pallets-eco/flask-session/commit/c7f8ced0e1532dea87850d34b3328a3fcb769988>`_, `c7f8ce <https://github.com/pallets-eco/flask-session/commit/c7f8ced0e1532dea87850d34b3328a3fcb769988>`_)
- Deprecate ``SESSION_USE_SIGNER`` (`a5dba7 <https://github.com/pallets-eco/flask-session/commit/a5dba7022f806c8fb4412d0428b69dd4a077e4a7>`_).
- Deprecate :class:`flask_session.filesystem.FileSystemSessionInterface` in favor of the broader :class:`flask_session.cachelib.CacheLibSessionInterface` (`2bc7df <https://github.com/pallets-eco/flask-session/commit/2bc7df1be7b8929e55cb25f13845caf0503630d8>`_).

Added
~~~~~~~
- All sessions that are accessed or modified while using 0.7.0 will convert to msgspec. Once using 1.0.0, any sessions that are still in pickle will be cleared upon access.
- Add time-to-live expiration for MongoDB (`9acee3 <https://github.com/pallets-eco/flask-session/commit/9acee3c5fb7072476f3feea923529d19d5e855c3>`_).
- Add retry for SQL based storage (`#211 <https://github.com/pallets-eco/flask-session/pull/211>`_).
- Add ``flask session_cleanup`` command and alternatively, ``SESSION_CLEANUP_N_REQUESTS`` for SQLAlchemy or future non-TTL backends (`#211 <https://github.com/pallets-eco/flask-session/pull/211>`_).
- Add type hints (`7d7d58 <https://github.com/pallets-eco/flask-session/commit/7d7d58ce371553da39095a421445cf639a62bd5f>`_).
- Add logo and additional documentation.
- Add vary cookie header when session modified or accessed as per flask's built-in session (`7ab698 <https://github.com/pallets-eco/flask-session/commit/7ab6980c8ba15912df13dd1e78242803e8104dd6>`_).
- Add regenerate method to session interface to mitigate fixation (`#27 <https://github.com/pallets-eco/flask-session/pull/27>`_, `#39 <https://github.com/pallets-eco/flask-session/issues/39>`_)(`80df63 <https://github.com/pallets-eco/flask-session/commit/80df635ffd466fa7798f6031be5469b4d5dae069>`_).

Removed
~~~~~~~~~~
- Remove null session in favour of relevant exception messages (`#107 <https://github.com/pallets-eco/flask-session/issues/107>`_, `#182 <https://github.com/pallets-eco/flask-session/issues/182>`_)(`d7ed1c <https://github.com/pallets-eco/flask-session/commit/d7ed1c6e7eb3904888b72f0d6c006db1b9b60795>`_).
- Drop support for Python 3.7 which is end-of-life and precludes use of msgspec (`bd7e5b <https://github.com/pallets-eco/flask-session/commit/bd7e5b0bbfc10cdfa9c83b859593c69cc4381571>`_).

Fixed
~~~~~
- Prevent session identifier reuse on storage miss (`#76 <https://github.com/pallets-eco/flask-session/pull/76>`_).
- Abstraction to improve consistency between backends.
- Enforce ``PERMANENT_SESSION_LIFETIME`` as expiration consistently for all backends (`#81 <https://github.com/pallets-eco/flask-session/issues/81>`_)(`86895b <https://github.com/pallets-eco/flask-session/commit/86895b523203ca67c9f87416bdbf028852dcb357>`_).
- Specifically include backend session interfaces in public API and document usage (`#210 <https://github.com/pallets-eco/flask-session/issues/210>`_).
- Fix non-permanent sessions not updating expiry (`#221 <https://github.com/pallets-eco/flask-session/issues/221>`_).


0.6.0 - 2024-01-16
------------------

Changed
~~~~~~~~

- Use :meth:`~ServerSideSession.should_set_cookie` for preventing each request from saving the session again.
- Do not store a permanent session that is otherwise empty.
- Use `secrets` module to generate session identifiers, with 256 bits of entropy (was previously 122).
- Explicitly name support for ``python-memcached``, ``pylibmc`` and ``pymemcache`` for ``cachelib`` backend.

Added
~~~~~~~

- Introduce ``SESSION_KEY_LENGTH`` to control the length of the session key in bytes, default is 32.
- Support SQLAlchemy ``SESSION_SQLALCHEMY_SEQUENCE``, ``SESSION_SQLALCHEMY_SCHEMA`` and ``SESSION_SQLALCHEMY_BINDKEY``

Removed
~~~~~~~~~~

- Drop support for Redis < 2.6.12.

Fixed
~~~~~

- Use ``should_set_cookie`` for preventing each request from saving the session again.
- Permanent session otherwise empty will not be saved.
- Use `secrets` module to generate session identifiers, with 256 bits of
entropy (was previously 122).
- Explicitly name support for python-memcached, pylibmc and pymemcache.
- Introduce SESSION_KEY_LENGTH to control the length of the session key in bytes, default is 32.
- Fix pymongo 4.0 compatibility.
- Fix expiry is None bug in SQLAlchemy.
- Fix bug when existing SQLAlchemy db instance.
- Support SQLAlchemy SESSION_SQLALCHEMY_SEQUENCE, SESSION_SQLALCHEMY_SCHEMA and SESSION_SQLALCHEMY_BINDKEY
- Drop support for Redis < 2.6.12.
- Fix empty sessions being saved.
- Support Flask 3.0 and Werkzeug 3.0

Version 0.5.0
-------------

Released 2023-05-11
0.5.0 - 2023-05-11
-------------------

- Drop support for Python < 3.7.
- Switch to ``pyproject.toml`` and Flit for packaging.
- Move to Pallets Community Ecosystem for community-driven maintenance.
- Replace use of ``session_cookie_name`` for Flask 2.3 compatibility.


Version 0.4.1
0.4.1
-------------

- Temporarily pin Flask < 2.3.


Version 0.4.0
0.4.0
-------------

- Added support for ``SESSION_COOKIE_SAMESITE``.


Version 0.3.2
0.3.2
-------------

- Changed ``werkzeug.contrib.cache`` to ``cachelib``.


Version 0.3.1
0.3.1
-------------

- ``SqlAlchemySessionInterface`` is using ``VARCHAR(255)`` to store session id now.
- ``SqlAlchemySessionInterface`` won't run `db.create_all` anymore.


Version 0.3
0.3
-----------

- ``SqlAlchemySessionInterface`` is using ``LargeBinary`` type to store data now.
- Fixed ``MongoDBSessionInterface`` ``delete`` method not found.
- Fixed ``TypeError`` when getting ``store_id`` using a signer.


Version 0.2.3
0.2.3
-------------

- Fixed signing failure in Python 3.
Expand All @@ -70,33 +116,33 @@ Version 0.2.3
- Fixed ``StrictRedis`` support.


Version 0.2.2
0.2.2
-------------

- Added support for non-permanent session.


Version 0.2.1
0.2.1
-------------

- Fixed signing failure.


Version 0.2
0.2
-----------

- Added ``SqlAlchemySessionInterface``.
- Added support for cookie session id signing.
- Various bugfixes.


Version 0.1.1
0.1.1
-------------

Fixed MongoDB backend ``InvalidDocument`` error.
- Fixed MongoDB backend ``InvalidDocument`` error.


Version 0.1
0.1
-----------

- First public preview release.
77 changes: 62 additions & 15 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -1,32 +1,79 @@
Getting started
-------------
-----------------
Using pip
~~~~~~~~~~~

Navigate to the project directory and run the following commands:

Create and activate a virtual environment
.. code-block:: text
python -m venv .venv
.\venv\bin\activate

.. code-block:: bash

$ python -m venv .venv
$ source .venv/bin/activate

Install dependencies
.. code-block:: text
pip install -r requirements/dev.txt
pip install -r requirements/pytest.txt

.. code-block:: bash

Install Memecached and Redis and activate local server (optional)
.. code-block:: text
brew install memcached
brew install redis
$ pip install -r requirements/dev.in
$ pip install -r requirements/docs.in

Install the package in editable mode

.. code-block:: bash

$ pip install -e .

Lint the code

.. code-block:: bash

$ ruff check --fix

Build updated documentation locally

.. code-block:: bash

$ cd docs
$ make html

or

.. code-block:: bash

$ sphinx-build -b html docs docs/_build

Run the tests together or individually
.. code-block:: text
pytest tests
pytest tests/test_basic.py

.. code-block:: bash

$ pytest tests
$ pytest tests/test_basic.py

For easier startup and teardown of storage for testing you may use

.. code-block:: bash

$ docker-compose up -d
$ docker-compose down

Using rye
~~~~~~~~~~~

.. code-block:: bash

$ rye pin 3.11
$ rye sync


.. code-block:: bash

$ rye run python examples/hello.py


etc.

Pull requests
-------------
--------------
Please check previous pull requests before submitting a new one.
23 changes: 23 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Contributors

- [nebolax](https://github.com/nebolax)
- [Taragolis](https://github.com/Taragolis)
- [Lxstr](https://github.com/Lxstr)
- [yrro](https://github.com/yrro)
- [hluk](https://github.com/hluk)
- [idoshr](https://github.com/idoshr)
- [rayluo](https://github.com/rayluo)
- [davidism](https://github.com/davidism)
- [idocyabra](https://github.com/idocyabra)
- [darless](https://github.com/darless)
- [SqrtMinusOne](https://github.com/SqrtMinusOne)
- [tylersalminen](https://github.com/tylersalminen)
- [warrenbailey](https://github.com/warrenbailey)
- [imacat](https://github.com/imacat)
- [kim-sondrup](https://github.com/kim-sondrup)
- [bnjmn](https://github.com/bnjmn)
- [christopherpickering](https://github.com/christopherpickering)

## Original Author

- [fengsp](https://github.com/fengsp)
Loading
Loading