xpra icon
Bug tracker and wiki

Ticket #1664: hsts.patch

File hsts.patch, 1.8 KB (added by Antoine Martin, 3 years ago)

example adding hsts headers with a hardcoded value

  • xpra/net/websocket.py

     
    3131    keep_alive = WEBSOCKET_TCP_KEEPALIVE
    3232    server_version = "Xpra-WebSockify"
    3333
    34     def __init__(self, sock, addr, new_websocket_client, web_root="/usr/share/xpra/www/", script_paths={}):
     34    def __init__(self, sock, addr, new_websocket_client, web_root="/usr/share/xpra/www/", script_paths={}, hsts=0):
    3535        self.web_root = web_root
    3636        self._new_websocket_client = new_websocket_client
    3737        self.script_paths = script_paths
     38        self.hsts = hsts
    3839        server = AdHocStruct()
    3940        server.logger = log
    4041        server.run_once = True
     
    9596                self.send_header("Echo-Accept-Language", std(accept, extras="-,./:;="))
    9697        if HTTP_NOCACHE:
    9798            self.send_nocache_headers()
     99        log.info("self.hsts=%s", self.hsts)
     100        if self.hsts>0:
     101            self.send_header("Strict-Transport-Security", "max-age=%i; includeSubDomains" % self.hsts)
    98102        WebSocketRequestHandler.end_headers(self)
    99103
    100104    def send_nocache_headers(self):
  • xpra/server/server_core.py

     
    10141014                socktype = "ws%s" % ["","s"][int(is_ssl)]
    10151015                self.make_protocol(socktype, wsc)
    10161016            scripts = self.get_http_scripts()
    1017             WSRequestHandler(sock, frominfo, new_websocket_client, self._www_dir, scripts)
     1017            WSRequestHandler(sock, frominfo, new_websocket_client, self._www_dir, scripts, 300)
    10181018            return
    10191019        except IOError as e:
    10201020            wslog("", exc_info=True)