allow websocket connections from files and localhost and use it in installer and static load file
This commit is contained in:
parent
01caf50ffa
commit
871a602acd
2 changed files with 39 additions and 13 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue