コード例 #1
0
import time
import traceback

from components.registrators.base import BaseRegistrator
from handlers.aws import ThingHandler
from handlers.exceptions import ThingNotExists
from handlers.utils import Logger
from handlers.authorization.schemas import RegisterAwsIoTThingSchema, RequestAwsIoTThingSchema

project_logger = Logger()
logger = project_logger.get_logger()


class AwsIoTGenericRegistrator(BaseRegistrator):
    class Meta:
        WORKERS = {
            "request_validation_handler": RequestAwsIoTThingSchema,
            "registration_validation_handler": RegisterAwsIoTThingSchema,
            "thing_handler": ThingHandler,
        }

    def __init__(self, device_request_data):
        super(AwsIoTGenericRegistrator, self).__init__(device_request_data)

        self.request_validation_handler = self.Meta.WORKERS[
            "request_validation_handler"]()
        self.registration_validation_handler = self.Meta.WORKERS[
            "registration_validation_handler"]()
        self.thing_handler = self.Meta.WORKERS["thing_handler"]()

    def validate_request(self) -> bool:
コード例 #2
0
from handlers.aws import ConfigurationHandler
from settings.aws import APP_CONFIG_PATH
from handlers.utils import Logger


logs_handler = Logger()
logger = logs_handler.get_logger()


class BaseApiGwAuthorizer:
    class Meta:
        """
        Define the Worker Classes for the base steps in the authorization process.
        """

        WORKERS = {
            "request_validation_handler": None,
            "token_validation_handler": None,
            "token_authorization_handler": None,
            "policy_handler": None,
        }

    def __init__(self, authorization_request_data: dict, *args, **kwargs):
        self.configuration_handler = None
        self.configuration_data = self.get_configuration()

        self.authorization_request_data = authorization_request_data

        self.valid_request_data = None
        self.valid_token_data = None
        self.token_authorization_handler = None