diff --git a/python/tank/authentication/login_dialog.py b/python/tank/authentication/login_dialog.py index fd2452962..15463e120 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 6a1aae46b..289275d2d 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/commit_id b/python/tank/authentication/sso_saml2/commit_id deleted file mode 100644 index ff3953774..000000000 --- a/python/tank/authentication/sso_saml2/commit_id +++ /dev/null @@ -1 +0,0 @@ -e8e4f97d101b0869a303f7514dcc4c8cf8574a4d diff --git a/python/tank/authentication/sso_saml2/sso_saml2.py b/python/tank/authentication/sso_saml2/sso_saml2.py index a1454b6e7..cc16b62b3 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 minimal 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_rv.py b/python/tank/authentication/sso_saml2/sso_saml2_rv.py deleted file mode 100644 index ee19d9d6b..000000000 --- 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() 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 b3d130314..000000000 --- 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 3fce6dcca..2fd075407 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 19af6048e..273dbf381 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,