From 036877e897120205723b8e5b8ab81e4d1c1d130e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 21 May 2018 23:31:55 +0200 Subject: [PATCH] sessions: use dedicated get_sessions_for_saml in SQL backend (#23972) --- wcs/qommon/sessions.py | 16 +++++++++------- wcs/sql.py | 3 ++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/wcs/qommon/sessions.py b/wcs/qommon/sessions.py index e5de859d..18856373 100644 --- a/wcs/qommon/sessions.py +++ b/wcs/qommon/sessions.py @@ -321,6 +321,13 @@ class Session(QommonSession, CaptchaSession, StorableObject): d[prefix + 'user_' + k] = v return d + @classmethod + def get_sessions_for_saml(cls, name_identifier=Ellipsis, session_indexes=()): + return (x for x in cls.values() + if (not session_indexes + or x.lasso_session_index in session_indexes) + and name_identifier in (x.name_identifier or [])) + class QommonSessionManager(QuixoteSessionManager): def start_request(self): @@ -398,13 +405,8 @@ class StorageSessionManager(QommonSessionManager): if session: session.clean_form_tokens() - def get_sessions_for_saml(self, name_identifier = Ellipsis, \ - session_indexes = ()): - ret = (x for x in self.values() \ - if (not session_indexes \ - or x.lasso_session_index in session_indexes) \ - and name_identifier in (x.name_identifier or [])) - return ret + def get_sessions_for_saml(self, name_identifier=Ellipsis, session_indexes=()): + return self.session_class.get_sessions_for_saml(name_identifier, session_indexes) def get_session_for_saml(self, name_identifier = None, session_index = None): if session_index: diff --git a/wcs/sql.py b/wcs/sql.py index 2fc6001a..9258c3e1 100644 --- a/wcs/sql.py +++ b/wcs/sql.py @@ -1831,7 +1831,8 @@ class Session(SqlMixin, wcs.sessions.BasicSession): setattr(o, k, v) return o - def get_sessions_for_saml(self, name_identifier=Ellipsis, *args, **kwargs): + @classmethod + def get_sessions_for_saml(cls, name_identifier=Ellipsis, *args, **kwargs): conn, cur = get_connection_and_cursor() sql_statement = '''SELECT %s -- 2.17.0