blob: 037a7c144e0ba6d14aec7e7108d161c049f46dd8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
def main(request, response):
def fmt(x):
return f'"{x.decode("utf-8")}"' if x is not None else "undefined"
purpose = request.headers.get("Purpose", b"").decode("utf-8")
sec_purpose = request.headers.get("Sec-Purpose", b"").decode("utf-8")
headers = [(b"Content-Type", b"text/html"), (b'WWW-Authenticate', 'Basic')]
status = 200 if request.auth.username is not None or sec_purpose.startswith(
"prefetch") else 401
content = f'''
<!DOCTYPE html>
<script src="/common/dispatcher/dispatcher.js"></script>
<script src="utils.sub.js"></script>
<script>
window.requestHeaders = {{
purpose: "{purpose}",
sec_purpose: "{sec_purpose}"
}};
window.requestCredentials = {{
username: {fmt(request.auth.username)},
password: {fmt(request.auth.password)}
}};
const uuid = new URLSearchParams(location.search).get('uuid');
window.executor = new Executor(uuid);
</script>
'''
return status, headers, content
|