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

403 (Forbidden) error when use .NET Table Storage SDK with DefaultAzureCredential #1062

Open PKPublicCode opened 2 years ago

PKPublicCode commented 2 years ago

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

Table storage

Which version of the Azurite was used?

3.14.2

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

NPM

What's the Node.js version?

14.17.6

What problem was encountered?

Azurite returns 403 Forbidden status when use .NET SDK DefaultAzureCredential and TableClient to connect table storage.

Steps to reproduce the issue?

nuget packages: Azure.Data.Tables 12.1.0 Azure.Identity 1.4.1

Azurite commandline: azurite --oauth basic --cert cert.pem --key key.pem Certificates generated with OpenSSL according to docs az login executed

Code to initialize client:

var client = new TableClient(new Uri("https://127.0.0.1:10002/devstoreaccount1/TestTable"), "TestTable", new DefaultAzureCredential());

Response from service:

Service request failed.
Status: 403 (Forbidden)

Content:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Error>
  <Code>AuthorizationFailure</Code>
  <Message>Server failed to authenticate the request. Make sure the value of the Authorization header is formed correctly including the signature.
RequestId:8991197f-9fe3-4697-b6e4-3305421d2e4d
Time:2021-09-25T13:25:17.378Z</Message>
</Error>

Headers:
Server: Azurite-Table/3.14.2
x-ms-error-code: REDACTED
x-ms-request-id: 8991197f-9fe3-4697-b6e4-3305421d2e4d
x-ms-version: REDACTED
Date: Sat, 25 Sep 2021 13:25:17 GMT
Connection: keep-alive
Keep-Alive: REDACTED
Transfer-Encoding: chunked
Content-Type: application/xml

Notes: Same code works well with azure azure table storage. Works well with azurite, same endpoint url and shared key credentials Experiments with Endpoint url didn't change results. Logs attached. tmp.log

Have you found a mitigation/solution?

No

XiaoningLiu commented 2 years ago

Hi @PKPublicCode. OAuth support for Table will be included in next release (merged into main branch already).

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.