From 6838553fa040a2654d29c07c03bf84d602d86f8f Mon Sep 17 00:00:00 2001 From: Elmir Jagudin Date: Thu, 16 Jan 2025 15:09:41 +0100 Subject: [PATCH] ISPyB LIMS: add a hook method for ISPyB authentication Add an abstract method ispyb_login(), which is invoked when auth server is set to 'ispyb'. This allow to implement ISPyB authentication by overriding this method in your custom ISPyB lims class. --- mxcubecore/HardwareObjects/ProposalTypeISPyBLims.py | 2 +- mxcubecore/HardwareObjects/UserTypeISPyBLims.py | 2 +- mxcubecore/HardwareObjects/abstract/ISPyBAbstractLims.py | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mxcubecore/HardwareObjects/ProposalTypeISPyBLims.py b/mxcubecore/HardwareObjects/ProposalTypeISPyBLims.py index efa2fcc40e..6e9b5a937b 100644 --- a/mxcubecore/HardwareObjects/ProposalTypeISPyBLims.py +++ b/mxcubecore/HardwareObjects/ProposalTypeISPyBLims.py @@ -62,7 +62,7 @@ def _authenticate(self, user_name, psd): ok = self.ldap_login(user_name, psd) elif self.authServerType == "ispyb": logging.getLogger("HWR").debug("ISPyB login") - ok, _ = self._ispybLogin(user_name, psd) + ok, _ = self.ispyb_login(user_name, psd) else: raise Exception("Authentication server type is not defined") diff --git a/mxcubecore/HardwareObjects/UserTypeISPyBLims.py b/mxcubecore/HardwareObjects/UserTypeISPyBLims.py index a6da253b8a..5b7041b41f 100644 --- a/mxcubecore/HardwareObjects/UserTypeISPyBLims.py +++ b/mxcubecore/HardwareObjects/UserTypeISPyBLims.py @@ -105,7 +105,7 @@ def login(self, loginID, psd, ldap_connection=None) -> LimsSessionManager: logging.getLogger("HWR").debug("User %s logged in LDAP" % login_name) elif self.authServerType == "ispyb": logging.getLogger("HWR").debug("ISPyB login") - ok, msg = self._ispybLogin(login_name, psd) + ok, msg = self.ispyb_login(login_name, psd) else: raise Exception("Authentication server type is not defined") diff --git a/mxcubecore/HardwareObjects/abstract/ISPyBAbstractLims.py b/mxcubecore/HardwareObjects/abstract/ISPyBAbstractLims.py index 59e8b56589..64c2c7fb90 100644 --- a/mxcubecore/HardwareObjects/abstract/ISPyBAbstractLims.py +++ b/mxcubecore/HardwareObjects/abstract/ISPyBAbstractLims.py @@ -129,6 +129,9 @@ def ldap_login(self, login_name, psd): return self.ldapConnection.authenticate(login_name, psd) + def ispyb_login(self, login_name, psd): + raise Exception("Abstract class. Not implemented") + def store_data_collection(self, mx_collection, bl_config=None): return self._store_data_collection(mx_collection, bl_config)