Flask Session using Azure Table Storage or CosmosDB table API
Project description
Flask Session using Azure table storage (or cosmosDB table API)
This module can be used as a Flask Session handler for Azure table storage or Azure CosmosDB. All stored data is encrypted using AES encryption.
Example usage:
import flask
from flask_session_azure import storage_account_interface
app = flask.Flask(__name__)
app.secret_key = "MyVerySecretEnryptionKeyForEverything" # must be at least 16 characters, the longer the better
connection_string = "DefaultEndpointsProtocol=https;AccountName=someAccount;AccountKey=someKey;EndpointSuffix=core.windows.net"
app.session_interface = storage_account_interface(connection_string)
This will store the session data in a table called flasksession
, with a partition key called default_session
. IF the table does not yet exists, it will be created the first time a session is stored.
You can overwrite these default when creating the session interface:
app.session_interface = storage_account_interface(connection_string, table_name="mytablename", partition_key="app1", create_table_if_not_exists=False)
If you use this in Azure Function, or Azure Web-Service, you most certainly already have a storage account connection in your environment variable AzureWebJobsStorage
:
import os
import flask
from flask_session_azure import storage_account_interface
app = flask.Flask(__name__)
app.secret_key = "MyVerySecretEnryptionKeyForEverything" # must be at least 16 characters, the longer the better
connection_string = os.environ.get("AzureWebjobsStorage")
app.session_interface = storage_account_interface(connection_string)
Changelog
0.4.3
- Fixed issue with secret key length and secret key containing non-asci characters
0.4.2
- Fixed issue if "samesite" cookie value was not set (i.e. set to none). If it is not set, it is now set to Lax to work in an azure function (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite)
0.4.1
- First public release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flask_session_azure-0.4.3.tar.gz
.
File metadata
- Download URL: flask_session_azure-0.4.3.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcfb854a068e61e47dd739f1fab5dbaf45c352fd8e93deebb3bdcf4b008ead07 |
|
MD5 | 91417d52e615de344faa7eb347a6b892 |
|
BLAKE2b-256 | cd138faea9da74b02939851a330f6c5de6c565526f59be69334907c8dfc6deb3 |
File details
Details for the file flask_session_azure-0.4.3-py3-none-any.whl
.
File metadata
- Download URL: flask_session_azure-0.4.3-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 022493231057183c16ebe2e68412e17aa04ebde452395086c05aac12da8564c0 |
|
MD5 | 1eda90da2f4b70a68092ac9fc53fe887 |
|
BLAKE2b-256 | 66acd43134a9f47c4f37e090ea12604c6fba5488cced810569b43cc0ef21773a |