mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-12-23 03:11:55 +00:00
Make TFWServer sign commands issued due to signed triggers
This commit is contained in:
parent
8ba99d8e36
commit
e846a2b111
@ -9,6 +9,7 @@ from tornado.web import Application
|
||||
from tfw.networking.event_handlers import ServerUplinkConnector
|
||||
from tfw.networking.server import EventHandlerConnector
|
||||
from tfw.networking import MessageSender
|
||||
from tfw.crypto import KeyManager, verify_message, sign_message
|
||||
from tfw.config.logs import logging
|
||||
from .zmq_websocket_proxy import ZMQWebSocketProxy
|
||||
|
||||
@ -24,6 +25,7 @@ class TFWServer:
|
||||
def __init__(self):
|
||||
self._event_handler_connector = EventHandlerConnector()
|
||||
self._uplink_connector = ServerUplinkConnector()
|
||||
self._auth_key = KeyManager().auth_key
|
||||
|
||||
self.application = Application([(
|
||||
r'/ws', ZMQWebSocketProxy, {
|
||||
@ -37,13 +39,16 @@ class TFWServer:
|
||||
def handle_trigger(self, message):
|
||||
if 'trigger' in message:
|
||||
LOG.debug('Executing handler for trigger "%s"', message.get('trigger', ''))
|
||||
self._uplink_connector.send_to_eventhandler({
|
||||
fsm_eh_command = {
|
||||
'key': 'fsm',
|
||||
'data': {
|
||||
'command': 'trigger',
|
||||
'value': message.get('trigger', '')
|
||||
'value': message['trigger']
|
||||
}
|
||||
})
|
||||
}
|
||||
if verify_message(self._auth_key, message):
|
||||
sign_message(self._auth_key, fsm_eh_command)
|
||||
self._uplink_connector.send_to_eventhandler(fsm_eh_command)
|
||||
|
||||
def handle_recover(self, message):
|
||||
if message['key'] == 'recover':
|
||||
|
Loading…
Reference in New Issue
Block a user