diff --git a/dbrepo-semantics-service/app.py b/dbrepo-semantics-service/app.py index 573e74fbf6d9c5d8dec2a90c2e21d880a6a1812e..70dceff24eb10379417fac433b28c1f8b48b1b76 100644 --- a/dbrepo-semantics-service/app.py +++ b/dbrepo-semantics-service/app.py @@ -13,6 +13,7 @@ from gevent.pywsgi import WSGIServer from save import insert_mdb_concepts, insert_mdb_units from onto_feat import list_ontologies, get_ontology from prometheus_flask_exporter import PrometheusMetrics +from flask_jwt_extended import jwt_required, JWTManager dictConfig({ 'version': 1, @@ -31,6 +32,7 @@ dictConfig({ }) app = Flask(__name__) +jwt = JWTManager(app) metrics = PrometheusMetrics(app) metrics.info('app_info', 'Application info', version='1.2.0') app.config['SWAGGER'] = {'openapi': '3.0.0', 'title': 'Swagger UI', 'uiversion': 3} @@ -194,6 +196,7 @@ def get_concept_label(): @app.route('/api/semantics/concept', methods=['POST'], endpoint='concepts_save') @swag_from('us-yml/post_concept.yml') +@jwt_required() def save_concept(): input_json = request.get_json() logging.debug('endpoint save concept, body=%s', input_json) @@ -216,7 +219,8 @@ def save_concept(): @app.route('/api/semantics/unit', methods=['POST'], endpoint='units_save') @swag_from('us-yml/post_unit.yml') -def save_concept(): +@jwt_required() +def save_unit(): input_json = request.get_json() logging.debug('endpoint save unit, body=%s', input_json) try: diff --git a/dbrepo-semantics-service/requirements.txt b/dbrepo-semantics-service/requirements.txt index 403f546c43e095d88d16d44b111332c189fa20c4..bf2f5a864c50536632b0af24dad167b4b3c8783a 100644 --- a/dbrepo-semantics-service/requirements.txt +++ b/dbrepo-semantics-service/requirements.txt @@ -36,4 +36,5 @@ zope.event==4.6 zope.interface==5.5.2 html5lib==1.1 pytest==7.2.1 -coverage==7.1.0 \ No newline at end of file +coverage==7.1.0 +Flask-JWT-Extended==4.4.4 \ No newline at end of file