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

Aberta
#170 0 comentários 0 reações 2 responsáveis Reivindicada por @SonOfLope Ver no GitHub
Linguagem predominante
Python
Estrelas
3
Forks
0
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

## 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.

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.