From 871a602acd0c430a07e05a45c9baa55992bd9f15 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 12 Aug 2014 14:51:38 +0200 Subject: [PATCH] allow websocket connections from files and localhost and use it in installer and static load file --- oml/websocket.py | 9 ++++++++- static/html/load.html | 43 +++++++++++++++++++++++++++++++------------ 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/oml/websocket.py b/oml/websocket.py index 94c0b94..58160f7 100644 --- a/oml/websocket.py +++ b/oml/websocket.py @@ -16,8 +16,15 @@ logger = logging.getLogger('oml.websocket') class Handler(WebSocketHandler): + def check_origin(self, origin): + # allow access to websocket from site, installer and loader (local file) + return self.request.host in origin \ + or origin == 'http://localhost:9842' \ + or origin == 'null' + def open(self): - if self.request.host not in self.request.headers['origin']: + if self.request.headers['origin'] not in ('null', 'http://localhost:9842') \ + and self.request.host not in self.request.headers['origin']: logger.debug('reject cross site attempt to open websocket %s', self.request) self.close() if self not in state.websockets: diff --git a/static/html/load.html b/static/html/load.html index 2c0c36f..6206d81 100644 --- a/static/html/load.html +++ b/static/html/load.html @@ -3,24 +3,43 @@ Open Media Library - - + + + + +
+
Starting Open Media Library
+ +