Generate SAS tokens with get_service_sas or get_account_sas

Open
#140 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
azure, r
Domain
cloud, security

Research direction

Start with the documented get_service_sas and get_account_sas entry points and reproduce the example using the supplied storage endpoint, key, container, and blob values. Compare the generated URL and its string-to-sign with the Azure authentication error; done means the SAS-appended blob URL authenticates successfully.

Written by the indexing model from the issue text.

Description

I'm trying to generate SAS tokens using the two functions mentioned above. Using example code in the docs (below) a SAS token is generated, however when I append this to the end of the blob I want to access I get an error stating the signature did not match.

I generate the SAS as follows:

endp <- storage_endpoint(Sys.getenv("LONDON_BUS_STORAGE_ENDPOINT"), key=Sys.getenv("LONDON_BUS_STORAGE_KEY"))

sas <- get_service_sas(endp, resource = Sys.getenv("LONDON_BUS_ANNOTATE_CONTAINER_NAME"), permissions="r")

blob_file_url_with_sas <- paste0(Sys.getenv("LONDON_BUS_STORAGE_ENDPOINT"), "/", Sys.getenv("LONDON_BUS_ANNOTATE_CONTAINER_NAME"), "/", Sys.getenv("LONDON_BUS_ANNOTATE_FILE"), sas)

Where the environmental variables relate to the storage account, storage account key, container name, and the name of the blob.

The error is:

<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:2b7236bd-301e-004c-2d6b-757ef4000000 Time:2024-03-13T17:22:19.7678924Z</Message> <AuthenticationErrorDetail>Signature did not match. String to sign used was r 2024-03-13T17:07:02Z 2024-03-14T01:07:02Z /blob/{{MY_STORAGE_ACCOUNT}}/{{MY_CONTAINER}} 2021-06-08 c </AuthenticationErrorDetail> </Error>

When I generate a SAS token in the GUI in my Azure account everything works. I'm only trying to generate with AzureStor so that I can generate frequently for extra security.

Any help on this is much appreciated. I've tried numerous variations of the SAS.

Dominant language
R
Stars
68
Forks
27
Avg merge
2d 7h
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Azure/AzureStor

All issues in Azure/AzureStor

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.