Open tpcgold opened 5 months ago
@tpcgold Could you please share the detailed error message when you use this SAS token? I checked the Portal behavior, e.g. when you are listing blobs in a container, the request is like below:
https://aacctestdt0606.blob.core.windows.net/%24logs?restype=container&comp=list&prefix=&delimiter=%2F&marker=&maxresults=30&include=metadata&sv=2022-11-02&ss=bqtf&srt=sco&sp=rwdlacuptfxiy&se=2024-06-20T17:27:57Z&sig=xxx
The sp
here is not following the order you shared. Suspicously the order is enforced in an earlier sv
, but relaxed since a later one.
the url is created like this in terraform
output "sas_url_staging" {
value = "${azurerm_storage_account.example.primary_blob_endpoint}${azapi_resource.example.name}${data.azurerm_storage_account_sas.example.sas}"
sensitive = true
}
which leads to a url like: https://example.blob.core.windows.net/example-container?sv=2017-07-29&ss=b&srt=s&sp=rwdlacuf&se=2025-01-01&st=2024-01-01&spr=https&sig=<signature>
the error output of the call:
<?xml version="1.0" encoding="utf-8"?>
<Error>
<Code>AuthenticationFailed</Code>
<Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:{uuid}
Time:{timestamp}</Message>
<AuthenticationErrorDetail>Signature fields not well formed.</AuthenticationErrorDetail>
</Error>
@tpcgold It turns out the signed_version
is too old (2017-07-29). You can explicitly set it to 2022-11-02
, which shall have support for the new permissions like filter
.
ok, I'll test with the explicit configuration. anyway, this seems to be a bug in the terraform provider script as the default seems to be 2017-07-29 🤔
Is there an existing issue for this?
Community Note
Terraform Version
1.13.1
AzureRM Provider Version
3.105.0
Affected Resource(s)/Data Source(s)
azurerm_storage_account_sas
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
SAS Token valid
Actual Behaviour
SAS token in the output is invalid as it's not following the requirements of https://learn.microsoft.com/en-us/rest/api/storageservices/create-service-sas
one example is the signedPermissions (sp) field order is not correct as is should be in following order (accoring to https://learn.microsoft.com/en-us/rest/api/storageservices/create-service-sas#specify-permissions):
racwdxltmeop
but the order is mixed in the terraform outputSteps to Reproduce
terraform apply example script read output SAS token
Important Factoids
No response
References
No response