]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: SSO not working after REST API versioning
authorAvan Thakkar <athakkar@redhat.com>
Thu, 26 Nov 2020 08:36:10 +0000 (14:06 +0530)
committerAvan Thakkar <athakkar@redhat.com>
Tue, 1 Dec 2020 06:44:38 +0000 (12:14 +0530)
Fixes: https://tracker.ceph.com/issues/48362
Signed-off-by: Avan Thakkar <athakkar@redhat.com>
saml2: Fix versioning parameter for saml2 endpoints, including minor fix for
endpoints with xml=true

src/pybind/mgr/dashboard/controllers/__init__.py
src/pybind/mgr/dashboard/controllers/saml2.py

index 5a7c165c658a9b3291a7c2e81a47146cedd341a7..2f3c186b952d502eb7b06c3db4f0334216ac4cba 100644 (file)
@@ -702,7 +702,11 @@ class BaseController(object):
             if isinstance(ret, bytes):
                 ret = ret.decode('utf-8')
             if xml:
-                cherrypy.response.headers['Content-Type'] = 'application/xml'
+                if version:
+                    cherrypy.response.headers['Content-Type'] = \
+                        'application/vnd.ceph.api.v{}+xml'.format(version)
+                else:
+                    cherrypy.response.headers['Content-Type'] = 'application/xml'
                 return ret.encode('utf8')
             if json_response:
                 if version:
index f53c7f0e1f665d866b5e5018ba64881653e22b00..76a7e193a9ac1d2a0ac2d24bd5134cd0271e2eb9 100644 (file)
@@ -16,7 +16,7 @@ from .. import mgr
 from ..exceptions import UserDoesNotExist
 from ..services.auth import JwtManager
 from ..tools import prepare_url_prefix
-from . import BaseController, Controller, Endpoint
+from . import BaseController, Controller, Endpoint, allow_empty_body
 
 
 @Controller('/auth/saml2', secure=False)
@@ -42,7 +42,8 @@ class Saml2(BaseController):
         except OneLogin_Saml2_Error:
             raise cherrypy.HTTPError(400, 'Single Sign-On is not configured.')
 
-    @Endpoint('POST', path="")
+    @Endpoint('POST', path="", version=None)
+    @allow_empty_body
     def auth_response(self, **kwargs):
         Saml2._check_python_saml()
         req = Saml2._build_req(self._request, kwargs)
@@ -78,27 +79,27 @@ class Saml2(BaseController):
             'reason': auth.get_last_error_reason()
         }
 
-    @Endpoint(xml=True)
+    @Endpoint(xml=True, version=None)
     def metadata(self):
         Saml2._check_python_saml()
         saml_settings = OneLogin_Saml2_Settings(mgr.SSO_DB.saml2.onelogin_settings)
         return saml_settings.get_sp_metadata()
 
-    @Endpoint(json_response=False)
+    @Endpoint(json_response=False, version=None)
     def login(self):
         Saml2._check_python_saml()
         req = Saml2._build_req(self._request, {})
         auth = OneLogin_Saml2_Auth(req, mgr.SSO_DB.saml2.onelogin_settings)
         raise cherrypy.HTTPRedirect(auth.login())
 
-    @Endpoint(json_response=False)
+    @Endpoint(json_response=False, version=None)
     def slo(self):
         Saml2._check_python_saml()
         req = Saml2._build_req(self._request, {})
         auth = OneLogin_Saml2_Auth(req, mgr.SSO_DB.saml2.onelogin_settings)
         raise cherrypy.HTTPRedirect(auth.logout())
 
-    @Endpoint(json_response=False)
+    @Endpoint(json_response=False, version=None)
     def logout(self, **kwargs):
         # pylint: disable=unused-argument
         Saml2._check_python_saml()