Refine the auth provider
[pti/o2.git] / o2app / entrypoints / flask_application.py
index 53e7e19..d55b50a 100644 (file)
@@ -18,16 +18,17 @@ from flask_restx import Api
 
 from o2app import bootstrap
 from o2ims.views import configure_namespace as ims_route_configure_namespace
-from o2dms.api import configure_namespace as dms_route_configure_namespace
+from o2common.views.route_exception import configure_exception
 
-from o2ims.adapter.clients.alarm_dict_client import load_alarm_definition
 from o2common.authmw import authmiddleware
 from o2common.authmw import authprov
 from o2common.config.config import get_review_url
 from o2common.helper import o2logging
 
+AUTH_ENABLED = True
+FLASK_API_VERSION = '1.0.0'
+
 # apibase = config.get_o2ims_api_base()
-auth = True
 app = Flask(__name__)
 logger = o2logging.get_logger(__name__)
 
@@ -40,7 +41,7 @@ def _get_k8s_url():
         raise Exception('Get k8s token review url failed')
 
 
-if auth:
+if AUTH_ENABLED:
     # perform service account identity&privilege check.
     _get_k8s_url()
     ad = authprov.auth_definer('ad')
@@ -50,13 +51,14 @@ if auth:
 app.config.SWAGGER_UI_DOC_EXPANSION = 'list'
 # app.config['RESTX_MASK_HEADER'] = 'fields'
 app.config['RESTX_MASK_SWAGGER'] = False
-api = Api(app, version='1.0.0',
-          title='INF O2 Services API',
-          description='Swagger OpenAPI document for the INF O2 Services',
+app.config['ERROR_INCLUDE_MESSAGE'] = False
+api = Api(
+    app, version=FLASK_API_VERSION,
+    catch_all_404s=True,
+    title='INF O2 Services API',
+    description='Swagger OpenAPI document for the INF O2 Services',
           )
 bus = bootstrap.bootstrap()
 
+configure_exception(api)
 ims_route_configure_namespace(api)
-dms_route_configure_namespace(api)
-
-load_alarm_definition(bus.uow)