tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

set_accounts_cookie.py (706B)


      1 def main(request, response):
      2  query_string = request.url_parts[3]
      3  # We mark the cookie as HttpOnly so that this request
      4  # can be made before login.html, which would overwrite
      5  # the value to 1.
      6  header_value = "accounts={}; SameSite=None; Secure; HttpOnly".format(query_string)
      7  response.headers.set(b"Set-Cookie", header_value.encode("utf-8"))
      8  response.headers.set(b"Content-Type", b"text/html")
      9 
     10  return """
     11 <!DOCTYPE html>
     12 <script>
     13 // The important part of this page are the headers.
     14 
     15 // If this page was opened as a popup, notify the opener.
     16 if (window.opener) {
     17  window.opener.postMessage("done_loading", "*");
     18  window.close();
     19 }
     20 </script>
     21 Sent header value: {}".format(header_value)
     22 """