Azure / Azure/azure-storage-python

Server failed to authenticate error when metadata values contain trailing whitespace

未关闭
#628 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
343
派生
243
PR 合并指标
30 天内没有已合并 PR

描述

### Which service(blob, file, queue) does this issue concern?
blob

### Which version of the SDK was used? Please provide the output of `pip freeze`.
azure-common==1.1.23
azure-storage-blob==2.1.0
azure-storage-common==2.1.0

### What problem was encountered?
Call to ` create_blob_from_bytes()` throws an error [azure.common.AzureHttpError] when any of the metadata values have leading or trailing whitespace.

```
azure.common.AzureHttpError: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. ErrorCode: AuthenticationFailed
AuthenticationFailedServer failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:78143b83-701e-0007-57a6-53ca4f000000
Time:2019-08-15T20:14:22.7942254ZThe MAC signature found in the HTTP request '(redacted base64 string)' is not the same as any computed signature. Server used following string to sign: 'PUT 61932 ...'
```

### Have you found a mitigation/solution?
Yes, trim all values in the metadata dict.

Old metadata (throws error):
```
metadata = {'LDate': '6/19/2018 12:15:16 PM', 'DocName': 'Utah Contracts 1 ', 'FileExtension': 'docx'}
service.create_blob_from_bytes(container, name, content, content_settings=content_settings, metadata=metadata)
```

New metadata (no error):
```
metadata = {'LDate': '6/19/2018 12:15:16 PM', 'DocName': 'Utah Contracts 1', 'FileExtension': 'docx'}
service.create_blob_from_bytes(container, name, content, content_settings=content_settings, metadata=metadata)
```

贡献指南

打开贡献指南

调研方向

按照 issue 中所示,使用包含前导或尾随空白的元数据,通过 create_blob_from_bytes() 重现该故障。跟踪 Azure Storage SDK 如何对该请求进行身份验证和签名,然后验证使用此类元数据的上传能够成功,同时现有的不带尾随空白的示例仍能正常工作。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
cloud
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。