Skip to content

Commit dfe8a3e

Browse files
committed
Server-side support for checking JWTs
1 parent e1f93c0 commit dfe8a3e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/server/api/admin_api.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
from config import engine
1212
from flask import request, redirect, jsonify, current_app, abort
1313
from api.file_uploader import validate_and_arrange_upload
14+
15+
from api import jwt_ops
1416
from config import (
1517
RAW_DATA_PATH,
1618
CURRENT_SOURCE_FILES_PATH,
@@ -26,6 +28,7 @@ def __allowed_file(filename):
2628

2729
# file upload tutorial
2830
@admin_api.route("/api/file", methods=["POST"])
31+
@jwt_ops.admin_required
2932
def uploadCSV():
3033
if "file" not in request.files:
3134
return redirect(request.url)
@@ -43,6 +46,7 @@ def uploadCSV():
4346

4447

4548
@admin_api.route("/api/listCurrentFiles", methods=["GET"])
49+
@jwt_ops.admin_required
4650
def list_current_files():
4751
result = None
4852

@@ -56,6 +60,7 @@ def list_current_files():
5660

5761

5862
@admin_api.route("/api/execute", methods=["GET"])
63+
@jwt_ops.admin_required
5964
def execute():
6065
current_app.logger.info("Execute flow")
6166
flow_script.start_flow()
@@ -109,6 +114,7 @@ def get_statistics():
109114

110115

111116
@admin_api.route("/api/statistics", methods=["GET"])
117+
@jwt_ops.admin_required
112118
def list_statistics():
113119
""" Pull Last Execution stats from DB. """
114120
current_app.logger.info("list_statistics() request")
@@ -134,6 +140,7 @@ def list_statistics():
134140

135141

136142
@admin_api.route("/api/get_execution_status/<int:job_id>", methods=["GET"])
143+
@jwt_ops.admin_required
137144
def get_exec_status(job_id):
138145
""" Get the execution status record from the DB for the specified job_id """
139146

src/server/api/common_api.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import dateutil.parser
1010
from secrets import SHELTERLUV_SECRET_TOKEN
1111

12+
from api import jwt_ops
13+
1214

1315
@common_api.route('/api/timeout_test/<duration>', methods=['GET'])
1416
def get_timeout(duration):
@@ -21,6 +23,7 @@ def get_timeout(duration):
2123
return results
2224

2325
@common_api.route('/api/contacts/<search_text>', methods=['GET'])
26+
@jwt_ops.jwt_required()
2427
def get_contacts(search_text):
2528
with engine.connect() as connection:
2629
search_text = search_text.lower()
@@ -45,6 +48,7 @@ def get_contacts(search_text):
4548

4649

4750
@common_api.route('/api/360/<matching_id>', methods=['GET'])
51+
@jwt_ops.jwt_required()
4852
def get_360(matching_id):
4953
result = {}
5054

0 commit comments

Comments
 (0)