summaryrefslogtreecommitdiff
path: root/src/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.py')
-rwxr-xr-xsrc/main.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/main.py b/src/main.py
index 4454f7d..fada6e9 100755
--- a/src/main.py
+++ b/src/main.py
@@ -28,6 +28,8 @@ app.add_middleware(
# TODO: X-Total-Count
+scheduler = JobScheduler()
+
@app.middleware("http")
async def mock_x_total_count_header(request: Request, call_next):
@@ -147,9 +149,7 @@ async def get_key(key=None, Authorize: AuthJWT = Depends()):
@app.post('/sc/v0/add')
async def add(data: Request, Authorize: AuthJWT = Depends()):
- # Maybe we should protect this enpoint too and let the scanner use
- # a JWT token as well.
- # Authorize.jwt_required()
+ Authorize.jwt_required()
json_data = await data.json()
@@ -180,6 +180,15 @@ async def jobs_get(Authorize: AuthJWT = Depends()):
return JSONResponse(content={"status": "success", "jobs": data})
+@app.get('/sc/v0/jobs/{job_id}')
+async def jobs_get_id(job_id, Authorize: AuthJWT = Depends()):
+ Authorize.jwt_required()
+
+ data = [JobScheduler.get_job(job_id)]
+
+ return JSONResponse(content={"status": "success", "jobs": data})
+
+
def main(standalone=False):
if not standalone:
return app