Azure / Azurite

A lightweight server clone of Azure Storage that simulates most of the commands supported by it with minimal dependencies
MIT License
1.8k stars 320 forks source link

HTTP 403 on QueueClient if SAS uri is used without start date #825

Open Kampfschildkroete opened 3 years ago

Kampfschildkroete commented 3 years ago

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

Queue

Which version of the Azurite was used?

Azurite-Queue/3.12.0

Where do you get Azurite? (npm, DockerHub, NuGet, Visual Studio Code Extension)

DockerHub

What's the Node.js version?

Unknown

What problem was encountered?

HTTP 403 for calls on QueueClient if SAS uri is used for initialization.

Steps to reproduce the issue?

var incomingQueueClient = new QueueClient("UseDevelopmentStorage=true", "test-queue", new QueueClientOptions() { MessageEncoding = QueueMessageEncoding.Base64 }); await incomingQueueClient.CreateIfNotExistsAsync(); var builder = new QueueSasBuilder { //StartsOn = DateTimeOffset.UtcNow.AddDays(-1), ExpiresOn = DateTimeOffset.UtcNow.AddDays(2) }; builder.SetPermissions(QueueSasPermissions.All); var sasUri = incomingQueueClient.GenerateSasUri(builder); var sasGeneratedQueue = new QueueClient(sasUri, new QueueClientOptions() { MessageEncoding = QueueMessageEncoding.Base64 }); await sasGeneratedQueue.ReceiveMessagesAsync(12); // this calls fails with HTTP 403

Have you found a mitigation/solution?

If you set a start for the SAS builder the call is successfull.

The problem is the if statement here that expects a start and expiry date. https://github.com/Azure/Azurite/blob/dbe5b715b94c52c1084e260ba312c88d3eb6c3d5/src/queue/authentication/QueueSASAuthenticator.ts#L329. But the documentation of Azure allows to omit the start date.

blueww commented 3 years ago

@Kampfschildkroete

Thanks for reporting this issue! We will evaluate it.

Azurite welcome contribution! It would be great if you can raise a PR to fix it!