Compare commits

...

2 Commits

Author SHA1 Message Date
Patrick Cloke 3d7e16dd30 Handle feedback given in #6634. 2020-03-25 10:49:10 -04:00
Patrick Cloke fd0ce13eb2 Remove unused class variable. 2020-03-25 09:40:27 -04:00
1 changed files with 6 additions and 9 deletions

View File

@ -15,7 +15,7 @@
import logging
import xml.etree.ElementTree as ET
from typing import Awaitable, Dict, Optional, Tuple
from typing import AnyStr, Awaitable, Dict, Optional, Tuple
from six.moves import urllib
@ -49,14 +49,11 @@ class CasHandler:
self._http_client = hs.get_proxied_http_client()
# cast to tuple for use with str.startswith
self._whitelisted_sso_clients = tuple(hs.config.sso_client_whitelist)
def _build_service_param(self, client_redirect_url: str) -> str:
return "%s%s?redirectUrl=%s" % (
def _build_service_param(self, client_redirect_url: AnyStr) -> str:
return "%s%s?%s" % (
self._cas_service_url,
"/_matrix/client/r0/login/cas/ticket",
urllib.parse.quote(client_redirect_url, safe=""),
urllib.parse.urlencode({"redirectUrl": client_redirect_url}),
)
def _handle_cas_response(
@ -153,12 +150,12 @@ class CasHandler:
registered_user_id, request, client_redirect_url
)
def handle_redirect_request(self, client_redirect_url: str) -> str:
def handle_redirect_request(self, client_redirect_url: bytes) -> bytes:
args = urllib.parse.urlencode(
{"service": self._build_service_param(client_redirect_url)}
)
return "%s/login?%s" % (self._cas_server_url, args)
return ("%s/login?%s" % (self._cas_server_url, args)).encode("ascii")
async def handle_ticket_request(self, request: SynapseRequest):
client_redirect_url = parse_string(request, "redirectUrl", required=True)