Commit df8c4829 authored by Daniele Venzano's avatar Daniele Venzano

Make ldap a soft requirement

parent 646fd446
......@@ -8,4 +8,3 @@ humanfriendly
psycopg2>=2.6.1
pyzmq>=15.2.0
typing
pyldap
......@@ -17,7 +17,10 @@
"""API component entry point."""
import sys
from zoe_api.entrypoint import zoe_web_main
if __name__ == "__main__":
zoe_web_main()
ret_val = zoe_web_main()
sys.exit(ret_val)
......@@ -17,7 +17,13 @@
import logging
import ldap
try:
import ldap
except ImportError:
ldap = None
LDAP_AVAILABLE = False
else:
LDAP_AVAILABLE = True
import zoe_api.auth.base
import zoe_api.exceptions
......
......@@ -27,6 +27,7 @@ import zoe_api.db_init
import zoe_api.api_endpoint
import zoe_api.rest_api
import zoe_api.web
import zoe_api.auth.ldap
log = logging.getLogger("zoe_api")
LOG_FORMAT = '%(asctime)-15s %(levelname)s %(name)s (%(threadName)s): %(message)s'
......@@ -44,6 +45,10 @@ def zoe_web_main() -> int:
else:
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
if config.get_conf().auth_type == 'ldap' and not zoe_api.auth.ldap.LDAP_AVAILABLE:
log.error("LDAP authentication requested, but 'pyldap' module not installed.")
return 1
log.info("Starting HTTP server...")
app = Flask(__name__, static_url_path='/does-not-exist')
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024
......@@ -66,3 +71,5 @@ def zoe_web_main() -> int:
ioloop.start()
except KeyboardInterrupt:
print("CTRL-C detected, terminating")
return 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment