Allow to configure mem storage from config (#1166)

* Allow to configure memory storage from config

* format

Co-authored-by: Adrià Casajús <adria.casajus@proton.ch>
This commit is contained in:
Adrià Casajús 2022-07-19 08:25:59 +02:00 committed by GitHub
parent 36547bd82d
commit afb2ab3758
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 292 additions and 1183 deletions

View File

@ -492,3 +492,6 @@ PARTNER_API_TOKEN_SECRET = os.environ.get("PARTNER_API_TOKEN_SECRET") or (
JOB_MAX_ATTEMPTS = 5
JOB_TAKEN_RETRY_WAIT_MINS = 30
# MEM_STORE
MEM_STORE_URI = os.environ.get("MEM_STORE_URI", None)

1464
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -110,6 +110,7 @@ twilio = "^7.3.2"
Deprecated = "^1.2.13"
cryptography = "37.0.1"
SQLAlchemy = "1.3.24"
redis = "^4.3.4"
[tool.poetry.dev-dependencies]
pytest = "^7.0.0"

View File

@ -4,6 +4,7 @@ import time
from datetime import timedelta
import arrow
import flask_limiter
import flask_profiler
import sentry_sdk
from coinbase_commerce.error import WebhookInvalidPayload, SignatureVerificationError
@ -69,6 +70,7 @@ from app.config import (
PAGE_LIMIT,
PADDLE_COUPON_ID,
ZENDESK_ENABLED,
MEM_STORE_URI,
)
from app.dashboard.base import dashboard_bp
from app.db import Session
@ -132,7 +134,6 @@ def create_app() -> Flask:
app = Flask(__name__)
# SimpleLogin is deployed behind NGINX
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1, x_host=1)
limiter.init_app(app)
app.url_map.strict_slashes = False
@ -153,6 +154,10 @@ def create_app() -> Flask:
if URL.startswith("https"):
app.config["SESSION_COOKIE_SECURE"] = True
app.config["SESSION_COOKIE_SAMESITE"] = "Lax"
if MEM_STORE_URI:
app.config[flask_limiter.extension.C.STORAGE_URL] = MEM_STORE_URI
limiter.init_app(app)
setup_error_page(app)