From 7987aeec33d2f46eec39fb139b3318f374d70cc6 Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Fri, 20 Jun 2025 10:17:56 -0700 Subject: [PATCH 1/4] Remove useless commit_id from old archived sso_saml2 repo --- python/tank/authentication/sso_saml2/commit_id | 1 - 1 file changed, 1 deletion(-) delete mode 100644 python/tank/authentication/sso_saml2/commit_id diff --git a/python/tank/authentication/sso_saml2/commit_id b/python/tank/authentication/sso_saml2/commit_id deleted file mode 100644 index ff39537747..0000000000 --- a/python/tank/authentication/sso_saml2/commit_id +++ /dev/null @@ -1 +0,0 @@ -e8e4f97d101b0869a303f7514dcc4c8cf8574a4d From 9e526b36c8e9a675750bdeab0b969a064dc1f480 Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Fri, 20 Jun 2025 10:18:32 -0700 Subject: [PATCH 2/4] Remove now unused sso_saml2_rv module --- .../authentication/sso_saml2/sso_saml2_rv.py | 82 ------------------- 1 file changed, 82 deletions(-) delete mode 100644 python/tank/authentication/sso_saml2/sso_saml2_rv.py diff --git a/python/tank/authentication/sso_saml2/sso_saml2_rv.py b/python/tank/authentication/sso_saml2/sso_saml2_rv.py deleted file mode 100644 index ee19d9d6bd..0000000000 --- a/python/tank/authentication/sso_saml2/sso_saml2_rv.py +++ /dev/null @@ -1,82 +0,0 @@ -# Copyright (c) 2017 Autodesk. -# -# CONFIDENTIAL AND PROPRIETARY -# -# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit -# Source Code License included in this distribution package. See LICENSE. -# By accessing, using, copying or modifying this work you indicate your -# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights -# not expressly granted therein are reserved by Shotgun Software Inc. -""" -Integration with Shotgun RV. -""" - -import json - -from .sso_saml2 import SsoSaml2 # noqa - - -class SsoSaml2Rv(SsoSaml2): - """ - This class provides a minimal interface to support SSO authentication. - """ - - def __init__(self, window_title=None, qt_modules=None): - """ - Create a SSO login dialog, using a Web-browser like environment. - - :param window_title: Title to use for the window. - :param qt_modules: a dictionnary of required Qt modules. - For Qt5/PySide2, we require modules QtCore, QtGui, - QtNetwork and QtWebEngineWidgets - - :returns: The SsoSaml2 oject. - """ - super(SsoSaml2Rv, self).__init__(window_title, qt_modules) - - def on_sso_login_cancel(self, event): - """ - Called to cancel an ongoing login attempt. - - :param event: RV event. Not used. - """ - self._logger.debug("Cancel SSO login attempt") - - # We only need to cancel if there is login attempt currently being made. - if self.is_handling_event(): - self.stop_session_renewal() - self.resolve_event(end_session=True) - self._dialog.accept() - - def on_sso_enable_renewal(self, event): - """ - Called when enabling automatic SSO session renewal. - - A new session will be created if there is not already a current one. - This will be in the case of the automatic (and successful) - authentication at the startup of the application. - - :param event: Json encoded document describing the RV event. - """ - self._logger.debug("SSO automatic renewal enabled") - - contents = json.loads(event.contents()) - - if self._session is None: - self.start_new_session( - { - "host": contents["params"]["site_url"], - "cookies": contents["params"]["cookies"], - } - ) - self.start_sso_renewal() - - def on_sso_disable_renewal(self, event): - """ - Called to disable automatic session renewal. - - This will be required when switching to a new connection (where the new - site may not using SSO) or at the close of the application. - """ - self._logger.debug("SSO automatic renewal disabled") - self.stop_session_renewal() From 213c81984bbfcbf2c5c6cae2126b5095f6c778ad Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Fri, 20 Jun 2025 10:21:03 -0700 Subject: [PATCH 3/4] Remove sso_saml2_toolkit module and refactor code to use sso_saml2 --- python/tank/authentication/login_dialog.py | 4 +-- .../tank/authentication/sso_saml2/__init__.py | 2 -- .../authentication/sso_saml2/sso_saml2.py | 13 +++++++ .../sso_saml2/sso_saml2_toolkit.py | 36 ------------------- .../test_interactive_authentication.py | 4 +-- tests/authentication_tests/test_web_login.py | 4 +-- 6 files changed, 19 insertions(+), 44 deletions(-) delete mode 100644 python/tank/authentication/sso_saml2/sso_saml2_toolkit.py diff --git a/python/tank/authentication/login_dialog.py b/python/tank/authentication/login_dialog.py index fd24529620..15463e1204 100644 --- a/python/tank/authentication/login_dialog.py +++ b/python/tank/authentication/login_dialog.py @@ -43,7 +43,7 @@ from . import site_info from .sso_saml2 import ( SsoSaml2IncompletePySide2, - SsoSaml2Toolkit, + SsoSaml2, SsoSaml2MissingQtModuleError, ) @@ -153,7 +153,7 @@ def __init__( "QtWebEngineWidgets": QtWebEngineWidgets, } try: - self._sso_saml2 = SsoSaml2Toolkit( + self._sso_saml2 = SsoSaml2( "Flow Production Tracking Web Login", qt_modules=qt_modules ) except SsoSaml2MissingQtModuleError as e: diff --git a/python/tank/authentication/sso_saml2/__init__.py b/python/tank/authentication/sso_saml2/__init__.py index 6a1aae46bf..289275d2d0 100644 --- a/python/tank/authentication/sso_saml2/__init__.py +++ b/python/tank/authentication/sso_saml2/__init__.py @@ -25,8 +25,6 @@ # Classes from .sso_saml2 import SsoSaml2 # noqa -from .sso_saml2_toolkit import SsoSaml2Toolkit # noqa - # Functions from .utils import ( # noqa get_saml_claims_expiration, diff --git a/python/tank/authentication/sso_saml2/sso_saml2.py b/python/tank/authentication/sso_saml2/sso_saml2.py index a1454b6e77..454775d9a8 100644 --- a/python/tank/authentication/sso_saml2/sso_saml2.py +++ b/python/tank/authentication/sso_saml2/sso_saml2.py @@ -135,3 +135,16 @@ def session_error(self): :returns: The session error string or "" """ return self._core._session.error + + def get_session_data(self): + """ + Get a mimimal subset of session data, for the Shotgun Toolkit. + + :returns: A tuple of the hostname, user_id, session_id and cookies. + """ + return ( + self._core._session.host, + self._core._session.user_id, + self._core._session.session_id, + self._core._session.cookies, + ) diff --git a/python/tank/authentication/sso_saml2/sso_saml2_toolkit.py b/python/tank/authentication/sso_saml2/sso_saml2_toolkit.py deleted file mode 100644 index b3d1303144..0000000000 --- a/python/tank/authentication/sso_saml2/sso_saml2_toolkit.py +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (c) 2017 Autodesk. -# -# CONFIDENTIAL AND PROPRIETARY -# -# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit -# Source Code License included in this distribution package. See LICENSE. -# By accessing, using, copying or modifying this work you indicate your -# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights -# not expressly granted therein are reserved by Shotgun Software Inc. -""" -Integration with Shotgun Toolkit API. -""" - -# pylint: disable=line-too-long -# pylint: disable=protected-access - -from .sso_saml2 import SsoSaml2 # noqa - - -class SsoSaml2Toolkit(SsoSaml2): - """ - This class provides a minimal interface to support SSO authentication. - """ - - def get_session_data(self): - """ - Get a mimimal subset of session data, for the Shotgun Toolkit. - - :returns: A tuple of the hostname, user_id, session_id and cookies. - """ - return ( - self._core._session.host, - self._core._session.user_id, - self._core._session.session_id, - self._core._session.cookies, - ) diff --git a/tests/authentication_tests/test_interactive_authentication.py b/tests/authentication_tests/test_interactive_authentication.py index 3fce6dcca4..2fd075407a 100644 --- a/tests/authentication_tests/test_interactive_authentication.py +++ b/tests/authentication_tests/test_interactive_authentication.py @@ -110,9 +110,9 @@ def done(self, r): self.my_result = r return super(MyLoginDialog, self).done(r) - # Patch out the SsoSaml2Toolkit class to avoid threads being created, which cause + # Patch out the SsoSaml2 class to avoid threads being created, which cause # issues with tests. - with mock.patch("tank.authentication.login_dialog.SsoSaml2Toolkit"): + with mock.patch("tank.authentication.login_dialog.SsoSaml2"): with contextlib.closing(MyLoginDialog(is_session_renewal, **kwargs)) as ld: try: self._prepare_window(ld) diff --git a/tests/authentication_tests/test_web_login.py b/tests/authentication_tests/test_web_login.py index 19af6048e6..273dbf381c 100644 --- a/tests/authentication_tests/test_web_login.py +++ b/tests/authentication_tests/test_web_login.py @@ -17,7 +17,7 @@ skip_if_pyside_missing, ) -from tank.authentication.sso_saml2 import SsoSaml2Toolkit +from tank.authentication.sso_saml2 import SsoSaml2 @only_run_on_nix # This test issues a seg-fault on Windows @@ -36,7 +36,7 @@ def test_web_login(self): if qt_abstraction.QtGui.QApplication.instance() is None: self._app = qt_abstraction.QtGui.QApplication([]) - obj = SsoSaml2Toolkit( + obj = SsoSaml2( "Test Web Login", qt_modules={ "QtCore": qt_abstraction.QtCore, From be2e81f8d8760c6f9356ab9a327d093601d22be0 Mon Sep 17 00:00:00 2001 From: Julien Langlois <16244608+julien-lang@users.noreply.github.com> Date: Fri, 20 Jun 2025 10:45:49 -0700 Subject: [PATCH 4/4] Update python/tank/authentication/sso_saml2/sso_saml2.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- python/tank/authentication/sso_saml2/sso_saml2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/tank/authentication/sso_saml2/sso_saml2.py b/python/tank/authentication/sso_saml2/sso_saml2.py index 454775d9a8..cc16b62b32 100644 --- a/python/tank/authentication/sso_saml2/sso_saml2.py +++ b/python/tank/authentication/sso_saml2/sso_saml2.py @@ -138,7 +138,7 @@ def session_error(self): def get_session_data(self): """ - Get a mimimal subset of session data, for the Shotgun Toolkit. + Get a minimal subset of session data, for the Shotgun Toolkit. :returns: A tuple of the hostname, user_id, session_id and cookies. """