|
53 | 53 | logger = logging.getLogger(__name__) |
54 | 54 |
|
55 | 55 |
|
56 | | -SUCCESS_TEMPLATE = """ |
57 | | -<html> |
58 | | -<head> |
59 | | -<title>Success!</title> |
60 | | -<meta name='viewport' content='width=device-width, initial-scale=1, |
61 | | - user-scalable=no, minimum-scale=1.0, maximum-scale=1.0'> |
62 | | -<link rel="stylesheet" href="/_matrix/static/client/register/style.css"> |
63 | | -<script> |
64 | | -if (window.onAuthDone) { |
65 | | - window.onAuthDone(); |
66 | | -} else if (window.opener && window.opener.postMessage) { |
67 | | - window.opener.postMessage("authDone", "*"); |
68 | | -} |
69 | | -</script> |
70 | | -</head> |
71 | | -<body> |
72 | | - <div> |
73 | | - <p>Thank you</p> |
74 | | - <p>You may now close this window and return to the application</p> |
75 | | - </div> |
76 | | -</body> |
77 | | -</html> |
78 | | -""" |
79 | | - |
80 | | - |
81 | 56 | class AuthHandler(BaseHandler): |
82 | 57 | SESSION_EXPIRE_MS = 48 * 60 * 60 * 1000 |
83 | 58 |
|
@@ -161,6 +136,11 @@ def __init__(self, hs): |
161 | 136 | self._sso_auth_confirm_template = load_jinja2_templates( |
162 | 137 | hs.config.sso_redirect_confirm_template_dir, ["sso_auth_confirm.html"], |
163 | 138 | )[0] |
| 139 | + # The following template is shown after a successful user interactive |
| 140 | + # authentication session. It tells the user they can close the window. |
| 141 | + self._sso_auth_success_template = hs.config.sso_auth_success_template |
| 142 | + # The following template is shown during the SSO authentication process if |
| 143 | + # the account is deactivated. |
164 | 144 | self._sso_account_deactivated_template = ( |
165 | 145 | hs.config.sso_account_deactivated_template |
166 | 146 | ) |
@@ -1091,12 +1071,12 @@ def complete_sso_ui_auth( |
1091 | 1071 | self._save_session(sess) |
1092 | 1072 |
|
1093 | 1073 | # Render the HTML and return. |
1094 | | - html_bytes = SUCCESS_TEMPLATE.encode("utf8") |
| 1074 | + html = self._sso_auth_success_template.encode("utf-8") |
1095 | 1075 | request.setResponseCode(200) |
1096 | 1076 | request.setHeader(b"Content-Type", b"text/html; charset=utf-8") |
1097 | | - request.setHeader(b"Content-Length", b"%d" % (len(html_bytes),)) |
| 1077 | + request.setHeader(b"Content-Length", b"%d" % (len(html),)) |
1098 | 1078 |
|
1099 | | - request.write(html_bytes) |
| 1079 | + request.write(html) |
1100 | 1080 | finish_request(request) |
1101 | 1081 |
|
1102 | 1082 | async def complete_sso_login( |
|
0 commit comments