Beispiel #1
0
 def auth(self, username, password):
     search_filter = "uid=" + username
     uid = None
     role = 'guest'
     try:
         self.connection.bind_s(self.bind_user, self.bind_password)
         result = self.connection.search_s(self.base_dn, ldap.SCOPE_SUBTREE,
                                           search_filter)
         user_dict = result[0][1]
         uid = username
         gid_numbers = [int(x) for x in user_dict['gidNumber']]
         if get_conf().ldap_admin_gid in gid_numbers:
             role = 'admin'
         elif get_conf().ldap_user_gid in gid_numbers:
             role = 'user'
         elif get_conf().ldap_guest_gid in gid_numbers:
             role = 'guest'
         else:
             log.warn(
                 'User {} has an unknown group ID ({}), using guest role'.
                 format(username, result[0][1]['gidNumber']))
             role = 'guest'
     except ldap.LDAPError:
         log.exception("LDAP exception")
     finally:
         self.connection.unbind_s()
     return uid, role
Beispiel #2
0
 def auth(self, username, password):
     search_filter = "uid=" + username
     uid = None
     role = 'guest'
     try:
         self.connection.bind_s(self.bind_user, self.bind_password)
         result = self.connection.search_s(self.base_dn, ldap.SCOPE_SUBTREE, search_filter)
         user_dict = result[0][1]
         uid = username
         gid_numbers = [int(x) for x in user_dict['gidNumber']]
         if get_conf().ldap_admin_gid in gid_numbers:
             role = 'admin'
         elif get_conf().ldap_user_gid in gid_numbers:
             role = 'user'
         elif get_conf().ldap_guest_gid in gid_numbers:
             role = 'guest'
         else:
             log.warn('User {} has an unknown group ID ({}), using guest role'.format(username, result[0][1]['gidNumber']))
             role = 'guest'
     except ldap.LDAPError:
         log.exception("LDAP exception")
     finally:
         self.connection.unbind_s()
     return uid, role
Beispiel #3
0
def init():
    dsn = 'dbname=' + get_conf().dbname + \
        ' user='******' password='******' host=' + get_conf().dbhost + \
        ' port=' + str(get_conf().dbport)

    conn = psycopg2.connect(dsn)
    cur = conn.cursor()

    version_table(cur)
    cur.execute('SET search_path TO {},public'.format(get_conf().deployment_name))
    if not check_schema_version(cur, get_conf().deployment_name):
        create_tables(cur)

    conn.commit()
    cur.close()
    conn.close()
    return
Beispiel #4
0
def zoe_web_main() -> int:
    """
    This is the entry point for the Zoe Web script.
    :return: int
    """
    config.load_configuration()
    args = config.get_conf()
    if args.debug:
        logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT)
    else:
        logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
    logging.getLogger("requests").setLevel(logging.WARNING)
    logging.getLogger("tornado").setLevel(logging.DEBUG)

    log.info("Starting HTTP server...")
    app = Flask(__name__, static_url_path='/does-not-exist')
    app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024

    zoe_api.db_init.init()

    api_endpoint = zoe_api.api_endpoint.APIEndpoint()
    config.api_endpoint = api_endpoint

    app.register_blueprint(zoe_api.rest_api.api_init(api_endpoint))
    app.register_blueprint(zoe_api.web.web_init())

    http_server = HTTPServer(WSGIContainer(app))
    http_server.listen(args.listen_port, args.listen_address)
    ioloop = IOLoop.instance()

    retry_cb = PeriodicCallback(api_endpoint.retry_submit_error_executions,
                                30000)
    retry_cb.start()

    try:
        ioloop.start()
    except KeyboardInterrupt:
        print("CTRL-C detected, terminating")
Beispiel #5
0
def zoe_web_main() -> int:
    """
    This is the entry point for the Zoe Web script.
    :return: int
    """
    config.load_configuration()
    args = config.get_conf()
    if args.debug:
        logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT)
    else:
        logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
    logging.getLogger("requests").setLevel(logging.WARNING)
    logging.getLogger("tornado").setLevel(logging.DEBUG)

    log.info("Starting HTTP server...")
    app = Flask(__name__, static_url_path='/does-not-exist')
    app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024

    zoe_api.db_init.init()

    api_endpoint = zoe_api.api_endpoint.APIEndpoint()
    config.api_endpoint = api_endpoint

    app.register_blueprint(zoe_api.rest_api.api_init(api_endpoint))
    app.register_blueprint(zoe_api.web.web_init())

    http_server = HTTPServer(WSGIContainer(app))
    http_server.listen(args.listen_port, args.listen_address)
    ioloop = IOLoop.instance()

    retry_cb = PeriodicCallback(api_endpoint.retry_submit_error_executions, 30000)
    retry_cb.start()

    try:
        ioloop.start()
    except KeyboardInterrupt:
        print("CTRL-C detected, terminating")
Beispiel #6
0
 def __init__(self):
     self.master = zoe_api.master_api.APIManager()
     self.sql = zoe_lib.sql_manager.SQLManager(get_conf())
Beispiel #7
0
 def __init__(self):
     self.connection = ldap.initialize(get_conf().ldap_server_uri)
     self.base_dn = get_conf().ldap_base_dn
     self.bind_user = get_conf().ldap_bind_user
     self.bind_password = get_conf().ldap_bind_password
Beispiel #8
0
 def __init__(self):
     self.context = zmq.Context(1)
     self.zmq_s = None
     self.poll = zmq.Poller()
     self.master_uri = config.get_conf().master_url
     self._connect()
Beispiel #9
0
 def __init__(self):
     self.context = zmq.Context(1)
     self.zmq_s = None
     self.poll = zmq.Poller()
     self.master_uri = config.get_conf().master_url
     self._connect()
Beispiel #10
0
 def __init__(self):
     self.connection = ldap.initialize(get_conf().ldap_server_uri)
     self.base_dn = get_conf().ldap_base_dn
     self.bind_user = get_conf().ldap_bind_user
     self.bind_password = get_conf().ldap_bind_password