Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix Internal Server Error on GET /saml2/authn_response #9623

Merged
merged 2 commits into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/9623.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix Internal Server Error on `GET /_synapse/client/saml2/authn_response` request.
10 changes: 8 additions & 2 deletions synapse/rest/synapse/client/saml2/response_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,30 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import TYPE_CHECKING

from synapse.http.server import DirectServeHtmlResource

if TYPE_CHECKING:
from synapse.server import HomeServer


class SAML2ResponseResource(DirectServeHtmlResource):
"""A Twisted web resource which handles the SAML response"""

isLeaf = 1

def __init__(self, hs):
def __init__(self, hs: "HomeServer"):
super().__init__()
self._saml_handler = hs.get_saml_handler()
self._sso_handler = hs.get_sso_handler()

async def _async_render_GET(self, request):
# We're not expecting any GET request on that resource if everything goes right,
# but some IdPs sometimes end up responding with a 302 redirect on this endpoint.
# In this case, just tell the user that something went wrong and they should
# try to authenticate again.
self._saml_handler._render_error(
self._sso_handler.render_error(
request, "unexpected_get", "Unexpected GET request on /saml2/authn_response"
)

Expand Down