blag commented on a change in pull request #21167:
URL: https://github.com/apache/airflow/pull/21167#discussion_r797313338
##########
File path: airflow/_vendor/flask_session/sessions.py
##########
@@ -0,0 +1,146 @@
+# ~~~~~~~~~~~~~~~~~~~~~~
+#
+# Server-side Sessions and SessionInterfaces.
+#
+# Originally copied from flask_session.sessions
+# Flask-Session
+# Copyright (C) 2014 by Shipeng Feng and other contributors
+# BSD, see LICENSE for more details.
+
+from datetime import datetime
+from uuid import uuid4
+try:
+ import cPickle as pickle
+except ImportError:
+ import pickle
+
+from flask.sessions import SessionInterface as FlaskSessionInterface
+from flask.sessions import SessionMixin as FlaskSessionMixin
+from werkzeug.datastructures import CallbackDict
+from itsdangerous import Signer, BadSignature, want_bytes
+
+from .db_models import Session as SessionModel
+
+
+class SQLAlchemySession(CallbackDict, FlaskSessionMixin):
+ """Baseclass for server-side based sessions."""
+
+ def __init__(self, initial=None, sid=None, permanent=None):
+ def on_update(self):
+ self.modified = True
+ super().__init__(initial, on_update)
+ self.sid = sid
+ if permanent:
+ self.permanent = permanent
+ self.modified = False
+
+
+class SessionInterface(FlaskSessionInterface):
+ def _generate_sid(self):
+ return str(uuid4())
+
+ def _get_signer(self, app):
+ if not app.secret_key:
+ return None
+ # The salt is combined with app.secret_key, and is used to "distinguish
+ # signatures in different contexts"
+ return Signer(app.secret_key, salt='airflow',
+ key_derivation='hmac')
+
+
+class SQLAlchemySessionInterface(SessionInterface):
+ """Uses the Flask-SQLAlchemy from a flask app as a session backend.
+
+ .. versionadded:: 0.2
+
+ :param db: A Flask-SQLAlchemy instance.
+ :param table: The table name you want to use.
+ :param key_prefix: A prefix that is added to all store keys.
+ :param use_signer: Whether to sign the session id cookie or not.
+ :param permanent: Whether to use permanent session or not.
+ """
+
+ serializer = pickle
Review comment:
Can we guarantee that all data being stored in the session is
JSON-serializable?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]