Merge pull request #38300 from rhcs-dashboard/fix-saml2-endpoint

mgr/dashboard: SSO not working after REST API versioning

Reviewed-by: Alfonso Martínez <almartin@redhat.com>
Reviewed-by: Ernesto Puerta <epuertat@redhat.com>
This commit is contained in:
Ernesto Puerta 2020-12-02 12:26:20 +01:00 committed by GitHub
commit c82876e292
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 7 deletions

View 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:

View 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()