@@ -32,19 +32,10 @@ def _build_req(request, post_data):
3232 'post_data' : post_data
3333 }
3434
35- @staticmethod
36- def _check_python_saml ():
37- if not python_saml_imported :
38- raise cherrypy .HTTPError (400 , 'Required library not found: `python3-saml`' )
39- try :
40- OneLogin_Saml2_Settings (mgr .SSO_DB .config .onelogin_settings )
41- except OneLogin_Saml2_Error :
42- raise cherrypy .HTTPError (400 , 'Single Sign-On is not configured.' )
43-
4435 @Endpoint ('POST' , path = "" , version = None )
4536 @allow_empty_body
4637 def auth_response (self , ** kwargs ):
47- Saml2 . _check_python_saml ()
38+ check_python_saml ()
4839 req = Saml2 ._build_req (self ._request , kwargs )
4940 auth = OneLogin_Saml2_Auth (req , mgr .SSO_DB .config .onelogin_settings )
5041 auth .process_response ()
@@ -84,30 +75,39 @@ def auth_response(self, **kwargs):
8475
8576 @Endpoint (xml = True , version = None )
8677 def metadata (self ):
87- Saml2 . _check_python_saml ()
78+ check_python_saml ()
8879 saml_settings = OneLogin_Saml2_Settings (mgr .SSO_DB .config .onelogin_settings )
8980 return saml_settings .get_sp_metadata ()
9081
9182 @Endpoint (json_response = False , version = None )
9283 def login (self ):
93- Saml2 . _check_python_saml ()
84+ check_python_saml ()
9485 req = Saml2 ._build_req (self ._request , {})
9586 auth = OneLogin_Saml2_Auth (req , mgr .SSO_DB .config .onelogin_settings )
9687 raise cherrypy .HTTPRedirect (auth .login ())
9788
9889 @Endpoint (json_response = False , version = None )
9990 def slo (self ):
100- Saml2 . _check_python_saml ()
91+ check_python_saml ()
10192 req = Saml2 ._build_req (self ._request , {})
10293 auth = OneLogin_Saml2_Auth (req , mgr .SSO_DB .config .onelogin_settings )
10394 raise cherrypy .HTTPRedirect (auth .logout ())
10495
10596 @Endpoint (json_response = False , version = None )
10697 def logout (self , ** kwargs ):
10798 # pylint: disable=unused-argument
108- Saml2 . _check_python_saml ()
99+ check_python_saml ()
109100 JwtManager .reset_user ()
110101 token = JwtManager .get_token (cherrypy .request )
111102 self ._delete_token_cookie (token )
112103 url_prefix = prepare_url_prefix (mgr .get_module_option ('url_prefix' , default = '' ))
113104 raise cherrypy .HTTPRedirect ("{}/#/login" .format (url_prefix ))
105+
106+
107+ def check_python_saml ():
108+ if not python_saml_imported :
109+ raise cherrypy .HTTPError (400 , 'Required library not found: `python3-saml`' )
110+ try :
111+ OneLogin_Saml2_Settings (mgr .SSO_DB .config .onelogin_settings )
112+ except OneLogin_Saml2_Error :
113+ raise cherrypy .HTTPError (400 , 'Single Sign-On is not configured.' )
0 commit comments