Skip to content

Commit

Permalink
[Model Monitoring] Pass access key in a different header (#1353)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hedingber committed Sep 24, 2021
1 parent 5287967 commit 6fe42fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions mlrun/api/utils/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ def authenticate_request(
# needed for data operations were passed through this header, keep reading it to be backwards compatible
if not auth_info.data_session and "X-V3io-Session-Key" in request.headers:
auth_info.data_session = request.headers["X-V3io-Session-Key"]
# In Iguazio 3.0 the ingress auth verification overrides the X-V3io-Session-Key from the auth response
# therefore the above won't work for requests coming from outside the cluster so allowing another header that
# won't be overridden
if not auth_info.data_session and "X-V3io-Access-Key" in request.headers:
auth_info.data_session = request.headers["X-V3io-Access-Key"]
return auth_info

def generate_auth_info_from_session(
Expand Down
8 changes: 4 additions & 4 deletions mlrun/db/httpdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2279,7 +2279,7 @@ def create_or_patch_model_endpoint(
method="PUT",
path=path,
body=model_endpoint.json(),
headers={"X-V3io-Session-Key": access_key},
headers={"X-V3io-Access-Key": access_key},
)

def delete_model_endpoint_record(
Expand All @@ -2301,7 +2301,7 @@ def delete_model_endpoint_record(

path = f"projects/{project}/model-endpoints/{endpoint_id}"
self.api_call(
method="DELETE", path=path, headers={"X-V3io-Session-Key": access_key},
method="DELETE", path=path, headers={"X-V3io-Access-Key": access_key},
)

def list_model_endpoints(
Expand Down Expand Up @@ -2356,7 +2356,7 @@ def list_model_endpoints(
"end": end,
"metric": metrics or [],
},
headers={"X-V3io-Session-Key": access_key},
headers={"X-V3io-Access-Key": access_key},
)
return schemas.ModelEndpointList(**response.json())

Expand Down Expand Up @@ -2399,7 +2399,7 @@ def get_model_endpoint(
"metric": metrics or [],
"feature_analysis": feature_analysis,
},
headers={"X-V3io-Session-Key": access_key},
headers={"X-V3io-Access-Key": access_key},
)
return schemas.ModelEndpoint(**response.json())

Expand Down

0 comments on commit 6fe42fd

Please sign in to comment.