Esempio n. 1
0
    def setUp(self):
        debug = False
        datadir = pkg_resources.resource_filename(__name__, 'data')
        self.config_file = os.path.join(datadir, 'test_config.ini')
        self.config = vccs_auth.config.VCCSAuthConfig(self.config_file, debug)
        self.credstore = FakeCredentialStore()
        self.kdf = ndnkdf.NDNKDF(self.config.nettle_path)
        self.keys = {
            0x2000: str('2000' * 16).decode('hex'),
            0x2001: str('2001' * 16).decode('hex'),
        }
        self.hasher = vccs_auth.hasher.VCCSSoftHasher(
            self.keys, vccs_auth.hasher.NoOpLock())
        self.logger = VCCSLogger('test_authbackend', syslog=False)

        #cherrypy.root = AuthBackend(self.hasher, self.kdf, self.logger, self.credstore, self.config)

        self.authbackend = AuthBackend(self.hasher,
                                       self.kdf,
                                       self.logger,
                                       self.credstore,
                                       self.config,
                                       expose_real_errors=True)
        cherrypy.tree.mount(self.authbackend, '/')
        cherrypy.engine.start()

        self.bcrypt_salt1 = '$2a$08$Ahy51oCM6Vg6d.1ScOPxse'
Esempio n. 2
0
 def setUp(self):
     debug = False
     datadir = pkg_resources.resource_filename(__name__, 'data')
     self.config_file = os.path.join(datadir, 'test_config.ini')
     self.config = vccs_auth.config.VCCSAuthConfig(self.config_file, debug)
     self.credstore = FakeCredentialStore()
     self.kdf = ndnkdf.NDNKDF(self.config.nettle_path)
     self.keys = {
         0x2000: str('2000' * 16).decode('hex'),
     }
     self.hasher = vccs_auth.hasher.VCCSSoftHasher(
         self.keys, vccs_auth.hasher.NoOpLock())
     self.logger = VCCSLogger('test_authbackend', self.config)
Esempio n. 3
0
    def setUp(self):
        self.ndnkdf = ndnkdf.NDNKDF()
        # This refers to the Python PBKDF2 implementation found at
        # https://www.dlitz.net/software/python-pbkdf2/ - It is imported here
        # to have only these tests fail if it is not present - not the whole
        # test suite.
        try:
            from pbkdf2 import PBKDF2
        except ImportError:
            import sys

            sys.stderr.write("python-pbkdf2 not available, get it from https://www.dlitz.net/software/python-pbkdf2/\n")
            sys.exit(1)
        self.other_pbkdf2 = PBKDF2
Esempio n. 4
0
def main(myname='vccs_authbackend'):
    """
    Initialize everything and start the authentication backend.

    :param myname: String used for logging
    """
    args = parse_args()

    # initialize various components
    config = vccs_auth.config.VCCSAuthConfig(args.config_file, args.debug)
    logger = VCCSLogger(myname, config)
    kdf = ndnkdf.NDNKDF(config.nettle_path)
    hsm_lock = threading.RLock()
    hasher = vccs_auth.hasher.hasher_from_string(config.yhsm_device,
                                                 hsm_lock,
                                                 debug=config.debug)
    credstore = VCCSAuthCredentialStoreMongoDB(config.mongodb_uri, logger)

    cherry_conf = {
        'server.thread_pool': config.num_threads,
        'server.socket_host': config.listen_addr,
        'server.socket_port': config.listen_port,
        # enables X-Forwarded-For, since BCP is to run this server
        # behind a webserver that handles SSL
        'tools.proxy.on': True,
    }
    if config.logdir:
        cherry_conf['log.access_file'] = os.path.join(config.logdir,
                                                      'access.log')
        cherry_conf['log.error_file'] = os.path.join(config.logdir,
                                                     'error.log')
    else:
        sys.stderr.write("NOTE: Config option 'logdir' not set.\n")
        cherry_conf['log.screen'] = True

    cherrypy.config.update(cherry_conf)

    logger.logger.info(
        "Starting server listening on {!s}:{!s} (loglevel {!r})".format(
            config.listen_addr, config.listen_port,
            logger.logger.getEffectiveLevel()))

    cherrypy.quickstart(AuthBackend(hasher, kdf, logger, credstore, config))
Esempio n. 5
0
    def setUp(self):

        self.ndnkdf = ndnkdf.NDNKDF()