ai-cfia / ai-cfia/ailab-datastore
As a dev, I want to resolve the issue with `get_user_container_client` failing due to incorrect authorization headers
- 主要語言
- Python
- 星號
- 3
- 分支
- 0
- PR 合併指標
- 30 天內沒有已合併 PR
描述
## Description
**Context**
Currently, when using the `datastore.get_user_container_client` function, it fails to authenticate the request correctly. Despite passing valid environment variables, the function throws an `azure.core.exceptions.ClientAuthenticationError` related to the Authorization header and signed times.
Sample code triggering the issue:
```python
import asyncio
import os
import datastore
BLOB_CONNECTION_STRING = os.environ["FERTISCAN_STORAGE_URL"]
if BLOB_CONNECTION_STRING is None or BLOB_CONNECTION_STRING == "":
raise ValueError("FERTISCAN_STORAGE_URL_TESTING is not set")
BLOB_ACCOUNT = os.environ["FERTISCAN_BLOB_ACCOUNT"]
if BLOB_ACCOUNT is None or BLOB_ACCOUNT == "":
raise ValueError("NACHET_BLOB_ACCOUNT is not set")
BLOB_KEY = os.environ["FERTISCAN_BLOB_KEY"]
if BLOB_KEY is None or BLOB_KEY == "":
raise ValueError("NACHET_BLOB_KEY is not set")
container_client = asyncio.run(
datastore.get_user_container_client(
user_id="user",
storage_url=BLOB_CONNECTION_STRING,
account=BLOB_ACCOUNT,
key=BLOB_KEY,
tier="test-user",
)
)
```
**Problem Statement**
When calling `datastore.get_user_container_client`, the following error occurs:
```
azure.core.exceptions.ClientAuthenticationError: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:8a82ebb2-901e-0027-1295-111b8f000000
Time:2024-09-28T10:58:33.6544104Z
ErrorCode:AuthenticationFailed
authenticationerrordetail:Signed expiry time [Sat, 28 Sep 2024 07:03:33 GMT] has to be after signed start time [Sat, 28 Sep 2024 10:58:33 GMT]
```
The error suggests that the signed expiry time is incorrectly set before the signed start time, which is causing the failure.
## Acceptance Criteria
- Investigate and fix the issue in `datastore.get_user_container_client` where the authorization headers are incorrectly formed.
貢獻指南
這個儲存庫沒有索引到貢獻指南
評估
這個 Issue 還沒有評估資料。