3
3
from azure .identity import DefaultAzureCredential
4
4
from azure .keyvault .secrets import SecretClient
5
5
6
+ from cachelib .file import FileSystemCache
7
+
6
8
# Configure Azure Key Vault
7
9
KEY_VAULT_URL = os .getenv ("AZURE_KEY_VAULT_URL" , "https://your-keyvault-name.vault.azure.net" )
8
10
credential = DefaultAzureCredential ()
@@ -49,7 +51,7 @@ def get_secret(secret_name: str) -> str:
49
51
#LIMITS_DB_PORT = os.getenv("LIMITS_DB_PORT") or 6379
50
52
51
53
# Tells the Flask-session extension to store sessions in the filesystem
52
- SESSION_TYPE = "filesystem "
54
+ SESSION_TYPE = "cachelib "
53
55
# In production, your setup may use multiple web servers behind a load balancer,
54
56
# and the subsequent requests may not be routed to the same web server.
55
57
# In that case, you may either use a centralized database-backed session store,
@@ -58,6 +60,8 @@ def get_secret(secret_name: str) -> str:
58
60
# [1] https://www.imperva.com/learn/availability/sticky-session-persistence-and-cookies/
59
61
# [2] https://azure.github.io/AppService/2016/05/16/Disable-Session-affinity-cookie-(ARR-cookie)-for-Azure-web-apps.html
60
62
# [3] https://learn.microsoft.com/en-us/azure/app-service/configure-common?tabs=portal#configure-general-settings
63
+ SESSION_SERIALIZATION_FORMAT = 'json'
64
+ SESSION_CACHELIB = FileSystemCache (threshold = 500 , cache_dir = "flask_session" )
61
65
62
66
# Flask secret key
63
67
SECRET_KEY = get_secret ("FLASK-SECRET-KEY" )
0 commit comments