allow websocket connections from files and localhost and use it in installer and static load file

This commit is contained in:
j 2014-08-12 14:51:38 +02:00
commit 871a602acd
2 changed files with 39 additions and 13 deletions

View file

@ -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: