예제 #1
0
    def __init__(self, timeout=30, **kwargs):

        scheme_args = {
            'title': "JWT Webhook",
            'description': "Retrieve data from jwt webhook using SSL",
            'use_single_instance': True
        }

        args = [
            IntegerField('port',
                         'Port',
                         'The port to run the web-server on',
                         none_allowed=False,
                         empty_allowed=False),
            Field(
                'secret',
                'Secret',
                'The secret key to decode the JWT encoded payload, leave it empty if the payload is not JWT encoded.',
                none_allowed=True,
                empty_allowed=True),
            Field(
                'path',
                'Path',
                'A wildcard that the path of requests must match (paths generally begin with a "/" and can include a wildcard)',
                none_allowed=True,
                empty_allowed=True),
            FilePathField(
                'key_file',
                'SSL Certificate Key File',
                'The path to the SSL certificate key file (if the certificate requires a key); typically uses .KEY file extension',
                none_allowed=True,
                empty_allowed=True,
                validate_file_existence=True),
            FilePathField(
                'cert_file',
                'SSL Certificate File',
                'The path to the SSL certificate file (if you want to use encryption); typically uses .DER, .PEM, .CRT, .CER file extensions',
                none_allowed=False,
                empty_allowed=False,
                validate_file_existence=True),
            Field(
                'password',
                'Password',
                'The password to decrypt the private key, leave it empty if the private key is not encrypted.',
                none_allowed=True,
                empty_allowed=True),
        ]

        ModularInput.__init__(self,
                              scheme_args,
                              args,
                              logger_name="webhook_modular_input",
                              sleep_interval=60)
        EventWriter.__init__(self, output=sys.stdout, error=sys.stderr)

        if timeout > 0:
            self.timeout = timeout
        else:
            self.timeout = 30

        self.http_daemons = {}