mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-12-23 15:51:56 +00:00
21 lines
584 B
Python
21 lines
584 B
Python
|
import logging
|
||
|
|
||
|
from tfw.internals.crypto import KeyManager, verify_message
|
||
|
|
||
|
from .event_handler import EventHandler
|
||
|
|
||
|
LOG = logging.getLogger(__name__)
|
||
|
|
||
|
|
||
|
# pylint: disable=abstract-method
|
||
|
class SignedEventHandler(EventHandler):
|
||
|
def __init__(self, connector):
|
||
|
self._auth_key = KeyManager().auth_key
|
||
|
super().__init__(connector)
|
||
|
|
||
|
def _event_callback(self, message):
|
||
|
if verify_message(self._auth_key, message):
|
||
|
self.handle_event(message, self.connector)
|
||
|
else:
|
||
|
LOG.error('Message does not have valid signature: %s', message)
|