Azure / Azure/azure-storage-python

azure-storage-blob - sas tokens for azurite container invalid in version 2.1.0

Đang mở
#668 2 bình luận 0 reaction 1 người được giao Được @xiafu-msft nhận Xem trên GitHub
Ngôn ngữ chính
Python
Star
343
Fork
243
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

- **Package Name**:
azure-storage-blob
- **Package Version**:
2.1.0
- **Operating System**:
OSX 10.15.5
- **Python Version**:
3.8
**Describe the bug**
sas tokens generated for files stored in azurite container (`arafato/azurite:2.6.5`) are invalid and container returns 403 response.
For same code and data, but with `azure-storage-blob==1.5.0` valid tokens are generated and data can be accessed.
(sas tokens generated for real azure storage blob are valid with `azure-storage-blob==2.1.0`)

**To Reproduce**
Steps to reproduce the behavior:

Sample code:
```
import datetime

import azure.storage.blob
import azure.storage.blob.sharedaccesssignature
import flask

APP = flask.Flask("my_app")

@APP.route("/")
def index():

# Account credentials for azurite container ccount
connection_string = "AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;DefaultEndpointsProtocol=http;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;"
container_name = "sketchpad"
account_name = "devstoreaccount1"
account_key = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="

shared_access = azure.storage.blob.sharedaccesssignature.BlobSharedAccessSignature(
account_name=account_name,
account_key=account_key)

blob_storage = azure.storage.blob.BlockBlobService(connection_string=connection_string)

urls = []

images_blobs = [blob for blob in blob_storage.list_blobs(container_name=container_name) if ".jpg" in blob.name]

for image_blob in images_blobs:

access_signature = shared_access.generate_blob(
container_name=container_name, blob_name=image_blob.name,
permission=azure.storage.blob.BlobPermissions.READ,
start=datetime.datetime.utcnow() - datetime.timedelta(minutes=10),
expiry=datetime.datetime.utcnow() + datetime.timedelta(hours=1),
content_type='image/jpeg'
)

url = blob_storage.make_blob_url(
container_name=container_name,
blob_name=image_blob.name,
sas_token=access_signature)

urls.append('Image here'.format(url))

images_data = "
".join(urls)

response = ("""


{}


""".format(images_data))

return response

APP.run(use_reloader=True)

```

**Expected behavior**
Generated URLs should be valid.

**Screenshots**
Access log (from azurite container) and URL generated for file `kitty_2.jpg` in container `sketchpad` with `azure-storage-blob==2.1.0`
```
GET /devstoreaccount1/sketchpad/kitty_2.jpg?st=2020-06-24T05%3A58%3A04Z&se=2020-06-24T07%3A08%3A04Z&sp=r&sv=2019-02-02&sr=b&rsct=image/jpeg&sig=f21aCsoNKYVAKql%2BwvLHalvx6SP5nxylxu4sBlak%2Bkk%3D 403 0.889 ms - 240
```

URL generated for the same file with `azure-storage-blob==1.5.0`:
```
GET /devstoreaccount1/sketchpad/kitty_2.jpg?st=2020-06-24T06%3A02%3A31Z&se=2020-06-24T07%3A12%3A31Z&sp=r&sv=2018-03-28&sr=b&rsct=image/jpeg&sig=uSO6uFlEVGJm8A9cJQ8bnZdHjapd3LmX4eFgSpy6sT0%3D 200 4.385 ms - 9767
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.