Skip to content

Commit

Permalink
chore: Rename crypto function for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
ramedina86 committed Dec 16, 2024
1 parent cf7b8c2 commit 0c47048
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/writer/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def get_hash(message: str):
combined = base_hash + HASH_SALT + message
return hashlib.sha256(combined.encode()).hexdigest()

def verify_hash_in_request(message: str, request: Request):
def verify_message_authorization_signature(message: str, request: Request):
auth_header = request.headers.get("Authorization")
if not auth_header:
raise HTTPException(status_code=401, detail="Unauthorized. Token not specified.")
Expand Down
4 changes: 2 additions & 2 deletions src/writer/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ async def _get_payload_as_json(request: Request):

@app.post("/api/job/workflow/{workflow_key}")
async def create_workflow_job(workflow_key: str, request: Request, response: Response):
crypto.verify_hash_in_request(f"create_job_{workflow_key}", request)
crypto.verify_message_authorization_signature(f"create_job_{workflow_key}", request)

def serialize_result(data):
if isinstance(data, list):
Expand Down Expand Up @@ -402,7 +402,7 @@ def job_done_callback(task: asyncio.Task, job_id: str):

@app.get("/api/job/{job_id}")
async def get_workflow_job(job_id: str, request: Request, response: Response):
crypto.verify_hash_in_request(f"get_job_{job_id}", request)
crypto.verify_message_authorization_signature(f"get_job_{job_id}", request)
job = app.state.job_vault.get(job_id)

if not job:
Expand Down

0 comments on commit 0c47048

Please sign in to comment.