Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
Lxstr committed Mar 26, 2024
2 parents d3c62c3 + 65c05ea commit cf943cf
Show file tree
Hide file tree
Showing 21 changed files with 321 additions and 28 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
outputs:
hash: ${{ steps.hash.outputs.hash }}
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c
with:
python-version: '3.x'
- run: pip install build
Expand All @@ -21,7 +21,7 @@ jobs:
- name: generate hash
id: hash
run: cd dist && echo "hash=$(sha256sum * | base64 -w0)" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
with:
path: ./dist
provenance:
Expand All @@ -31,7 +31,7 @@ jobs:
id-token: write
contents: write
# Can't pin with hash due to how this workflow works.
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.5.0
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.10.0
with:
base64-subjects: ${{ needs.build.outputs.hash }}
create-release:
Expand Down Expand Up @@ -60,6 +60,6 @@ jobs:
id-token: write
steps:
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
- uses: pypa/gh-action-pypi-publish@0bf742be3ebe032c25dd15117957dc15d0cfc38d
- uses: pypa/gh-action-pypi-publish@2f6f737ca5f74c637829c0f5c3acd0e29ea5e8bf
with:
packages-dir: artifact/
4 changes: 4 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ jobs:
image: mongo
ports:
- 27017:27017
dynamodb:
image: amazon/dynamodb-local
ports:
- 8000:8000
steps:
- uses: actions/checkout@v4
- uses: supercharge/redis-github-action@1.5.0
Expand Down
14 changes: 13 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
0.8.0 - 2024-03-26
------------------

Added
~~~~~~~
- Add DynamoDB session interface (`#214 <https://github.com/pallets-eco/flask-session/pull/214>`_).
- Add ability to install client libraries for backends using optional dependencies (extras) (`#228 <https://github.com/pallets-eco/flask-session/pull/228>`_).

Fixed
~~~~~
- Include prematurely removed ``cachelib`` dependency. Will be removed in 1.0.0 to be an optional dependency (`#223 <https://github.com/pallets-eco/flask-session/issues/223>`_).


0.7.0 - 2024-03-18
------------------

Expand All @@ -10,7 +23,6 @@ Changed

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>`_).
Expand Down
4 changes: 3 additions & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,6 @@ etc.

Pull requests
--------------
Please check previous pull requests before submitting a new one.
Please check previous pull requests before submitting a new one.

Please ensure your pull requests are to the `development` branch.
2 changes: 2 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Contributors

- [eiriklid](https://github.com/eiriklid)
- [necat1](https://github.com/necat1)
- [nebolax](https://github.com/nebolax)
- [Taragolis](https://github.com/Taragolis)
- [Lxstr](https://github.com/Lxstr)
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. image:: https://raw.githubusercontent.com/pallets-eco/flask-session/development/docs/_static/icon/favicon-192x192.png
.. image:: https://raw.githubusercontent.com/pallets-eco/flask-session/main/docs/_static/icon/favicon-192x192.png
:alt: Flask-Session
:target: https://flask-session.readthedocs.io
:align: left
Expand Down
16 changes: 12 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
version: '3.8'

services:
dynamodb-local:
image: "amazon/dynamodb-local:latest"
container_name: dynamodb-local
ports:
- "8000:8000"
environment:
- AWS_ACCESS_KEY_ID=dummy
- AWS_SECRET_ACCESS_KEY=dummy
- AWS_DEFAULT_REGION=us-west-2

mongo:
image: mongo:latest
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
ports:
- "27017:27017"
volumes:
Expand All @@ -26,4 +33,5 @@ services:
volumes:
postgres_data:
mongo_data:
redis_data:
redis_data:
dynamodb_data:
4 changes: 4 additions & 0 deletions docs/_static/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ table {
width: fill-available;
width: stretch;
}

.announcement-content {
white-space: unset !important;
}
3 changes: 2 additions & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ Anything documented here is part of the public API that Flask-Session provides,
.. autoclass:: flask_session.filesystem.FileSystemSessionInterface
.. autoclass:: flask_session.cachelib.CacheLibSessionInterface
.. autoclass:: flask_session.mongodb.MongoDBSessionInterface
.. autoclass:: flask_session.sqlalchemy.SqlAlchemySessionInterface
.. autoclass:: flask_session.sqlalchemy.SqlAlchemySessionInterface
.. autoclass:: flask_session.dynamodb.DynamoDBSessionInterface
30 changes: 22 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,45 @@
# HTML -----------------------------------------------------------------

favicons = [
{"rel": "icon", "href": "icon.svg", "type": "image/svg+xml"},
{"rel": "icon", "sizes": "16x16", "href": "favicon-16x16.png", "type": "image/png"},
{"rel": "icon", "sizes": "32x32", "href": "favicon-32x32.png", "type": "image/png"},
{"rel": "icon", "sizes": "48x48", "href": "favicon-48x48.png", "type": "image/png"},
{
"rel": "icon",
"sizes": "16x16",
"href": "icon/favicon-16x16.png",
"type": "image/png",
},
{
"rel": "icon",
"sizes": "32x32",
"href": "icon/favicon-32x32.png",
"type": "image/png",
},
{
"rel": "icon",
"sizes": "48x48",
"href": "icon/favicon-48x48.png",
"type": "image/png",
},
{
"rel": "icon",
"sizes": "192x192",
"href": "favicon-192x192.png",
"href": "icon/favicon-192x192.png",
"type": "image/png",
},
{
"rel": "icon",
"sizes": "512x512",
"href": "favicon-512x512.png",
"href": "icon/favicon-512x512.png",
"type": "image/png",
},
{
"rel": "apple-touch-icon",
"sizes": "180x180",
"href": "apple-touch-icon-180x180.png",
"href": "icon/apple-touch-icon-180x180.png",
"type": "image/png",
},
{
"rel": "mask-icon",
"href": "safari-pinned-tab.svg",
"href": "icon/safari-pinned-tab.svg",
},
]
html_copy_source = False
Expand Down
15 changes: 15 additions & 0 deletions docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,21 @@ SqlAlchemy

Default: ``None``

Dynamodb
~~~~~~~~~~~~~~~~~~~~~~~

.. py:data:: SESSION_DYNAMODB
A ``boto3.resource`` instance.
Default: Instance connected to ``'localhost:8000'``
.. py:data:: SESSION_DYNAMODB_TABLE_NAME
The name of the table you want to use.
Default: ``'Sessions'``
.. deprecated:: 0.7.0

``SESSION_FILE_DIR``, ``SESSION_FILE_THRESHOLD``, ``SESSION_FILE_MODE``. Use ``SESSION_CACHELIB`` instead.
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ requires-python = ">=3.8"
dependencies = [
"flask>=2.2",
"msgspec>=0.18.6",
"cachelib",
]
dynamic = ["version"]

Expand Down Expand Up @@ -84,4 +85,7 @@ dev-dependencies = [
"sphinx>=7.1.2",
"furo>=2024.1.29",
"sphinx-favicon>=1.0.1",
"boto3>=1.34.68",
"mypy_boto3_dynamodb>=1.34.67",
"pymemcache>=4.0.0",
]
7 changes: 5 additions & 2 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Core
flask>=2.2
msgspec
cachelib

# Linting
ruff
Expand All @@ -11,7 +12,9 @@ pytest-cov

# Requirements for interfaces
redis
python-memcached
pymemcache
Flask-SQLAlchemy
pymongo
cachelib
boto3
mypy_boto3_dynamodb

4 changes: 3 additions & 1 deletion requirements/docs.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ redis
cachelib
pymongo
flask_sqlalchemy
pymemcache
pymemcache
boto3
mypy_boto3_dynamodb
26 changes: 24 additions & 2 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ beautifulsoup4==4.12.3
# via furo
blinker==1.7.0
# via flask
boto3==1.34.69
# via -r requirements/docs.in
botocore==1.34.69
# via
# boto3
# s3transfer
cachelib==0.12.0
# via -r requirements/docs.in
certifi==2023.5.7
Expand Down Expand Up @@ -40,10 +46,16 @@ jinja2==3.1.2
# via
# flask
# sphinx
jmespath==1.0.1
# via
# boto3
# botocore
markupsafe==2.1.2
# via
# jinja2
# werkzeug
mypy-boto3-dynamodb==1.34.67
# via -r requirements/docs.in
packaging==23.1
# via sphinx
pygments==2.15.1
Expand All @@ -54,10 +66,16 @@ pymemcache==4.0.0
# via -r requirements/docs.in
pymongo==4.6.2
# via -r requirements/docs.in
python-dateutil==2.9.0.post0
# via botocore
redis==5.0.1
# via -r requirements/docs.in
requests==2.30.0
# via sphinx
s3transfer==0.10.1
# via boto3
six==1.16.0
# via python-dateutil
snowballstemmer==2.2.0
# via sphinx
soupsieve==2.5
Expand Down Expand Up @@ -87,8 +105,12 @@ sphinxcontrib-serializinghtml==1.1.5
sqlalchemy==2.0.27
# via flask-sqlalchemy
typing-extensions==4.10.0
# via sqlalchemy
# via
# mypy-boto3-dynamodb
# sqlalchemy
urllib3==2.0.2
# via requests
# via
# botocore
# requests
werkzeug==3.0.1
# via flask
15 changes: 15 additions & 0 deletions src/flask_session/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ def _get_interface(self, app):
"SESSION_CLEANUP_N_REQUESTS", Defaults.SESSION_CLEANUP_N_REQUESTS
)

# DynamoDB settings
SESSION_DYNAMODB = config.get("SESSION_DYNAMODB", Defaults.SESSION_DYNAMODB)
SESSION_DYNAMODB_TABLE = config.get(
"SESSION_DYNAMODB_TABLE", Defaults.SESSION_DYNAMODB_TABLE
)

common_params = {
"app": app,
"key_prefix": SESSION_KEY_PREFIX,
Expand Down Expand Up @@ -165,6 +171,15 @@ def _get_interface(self, app):
bind_key=SESSION_SQLALCHEMY_BIND_KEY,
cleanup_n_requests=SESSION_CLEANUP_N_REQUESTS,
)
elif SESSION_TYPE == "dynamodb":
from .dynamodb import DynamoDBSessionInterface

session_interface = DynamoDBSessionInterface(
**common_params,
client=SESSION_DYNAMODB,
table_name=SESSION_DYNAMODB_TABLE,
)

else:
raise ValueError(f"Unrecognized value for SESSION_TYPE: {SESSION_TYPE}")

Expand Down
4 changes: 4 additions & 0 deletions src/flask_session/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ class Defaults:
SESSION_SQLALCHEMY_SEQUENCE = None
SESSION_SQLALCHEMY_SCHEMA = None
SESSION_SQLALCHEMY_BIND_KEY = None

# DynamoDB settings
SESSION_DYNAMODB = None
SESSION_DYNAMODB_TABLE = "Sessions"
1 change: 1 addition & 0 deletions src/flask_session/dynamodb/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .dynamodb import DynamoDBSession, DynamoDBSessionInterface # noqa: F401
Loading

0 comments on commit cf943cf

Please sign in to comment.