Skip to content

claasd/FlaskAzureTableSession

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask Session using Azure table storage (or cosmosDB table API)

PyPI - License PyPI PyPI - Python Version

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

0.4.1

  • First public release

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages