Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/aleph/vm/orchestrator/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,11 @@ async def status_public_config(request: web.Request):
)


def authenticate_api_request(request: web.Request) -> bool:
def authenticate_api_request(request: web.Request, raises_on_missing_header=True) -> bool:
"""Authenticate an API request to update the VM allocations."""
signature: bytes = request.headers.get("X-Auth-Signature", "").encode()

if not signature:
if not signature and raises_on_missing_header:
raise web.HTTPUnauthorized(text="Authentication token is missing")

# Use a simple authentication method: the hash of the signature should match the value in the settings
Expand Down
4 changes: 2 additions & 2 deletions src/aleph/vm/orchestrator/views/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ async def stream_logs(request: web.Request) -> web.StreamResponse:

async def authenticate_for_vm_or_403(execution, request, vm_hash, ws):
"""Allow authentication via HEADER or via websocket"""
if authenticate_api_request(request):
logger.debug(f"Accepted request to access logs via the allocatioan api key on {vm_hash}")
if authenticate_api_request(request, raises_on_missing_header=False):
logger.debug(f"Accepted request to access logs via the allocation api key on {vm_hash}")
return True

first_message = await ws.receive_json()
Expand Down