Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[storage] GetSharedAccessSignature fails for containers with trailing slash #131

Closed
MartinWa opened this issue Nov 20, 2012 · 1 comment
Closed
Assignees

Comments

@MartinWa
Copy link

Given the following code:

var blobClient = account.CreateCloudBlobClient();
var container = blobClient.GetContainerReference(containerName);
CloudBlockBlob _blockblob = container.GetBlockBlobReference(fileName);
var sharedAccessPolicy = new SharedAccessBlobPolicy
{
SharedAccessStartTime = DateTime.UtcNow.AddMinutes(-10),
SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(30),
Permissions = SharedAccessBlobPermissions.Read
};
var sharedAccessSignature = _blockblob.GetSharedAccessSignature(sharedAccessPolicy);
var link = _blockblob.Uri.AbsoluteUri + sharedAccessSignature;

a AuthenticationFailed error will occur from the link if the containerName has a trailing slash (this is allowed in all other places).

The reason for this is that the GetCanonicalName method in CloudBlockBlobBase will add a slash to the container name resulting in a double slash. This is then signed and returned in the SAS. The AbsoluteUri however will not add the extra slash and thus the signature will not be valid for the created link.

A change in GetCanonicalName to trim any trailing slash from container name would solve this.

#131

@ghost ghost assigned jeffreyjirwin Mar 28, 2013
@ghost ghost assigned bradygaster-zz Dec 9, 2013
@stankovski
Copy link
Member

Please recreate in https://github.com/Azure/azure-storage-net/ if still relevant.

AzureRT pushed a commit to AzureRT/azure-sdk-for-net that referenced this issue Oct 21, 2015
hovsepm pushed a commit that referenced this issue Apr 25, 2016
Test changes for GET and Unregister Container
jethibau pushed a commit to jethibau/azure-sdk-for-net that referenced this issue Aug 2, 2018
* Correcting the return type of RoleAssignments::ListByScopeAsync

* Adding Domain dir and files for MSI

* Implementation for MSI fluent interfaces, adding MsiManager and exposing msi Identities collection in rollup client Azure

* Adding MSI tests

* Adding MSI tests recordings
@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants