Skip to content

feat(azure): expose split_sas for custom SAS credential providers#721

Open
dbatomic wants to merge 1 commit into
apache:mainfrom
dbatomic:expose-azure-split-sas
Open

feat(azure): expose split_sas for custom SAS credential providers#721
dbatomic wants to merge 1 commit into
apache:mainfrom
dbatomic:expose-azure-split-sas

Conversation

@dbatomic
Copy link
Copy Markdown

@dbatomic dbatomic commented May 11, 2026

Which issue does this PR close?

Closes #720.

Rationale for this change

Users implementing their own CredentialProvider<Credential = AzureCredential> that fetches SAS tokens at request time (e.g. tokens refreshed from a secret manager or coordination service) currently have to reimplement this parser to feed pairs into
AzureCredential::SASToken. Reimplementations are easy to get subtly wrong: in particular, using form_urlencoded decodes + as space, which corrupts base64-encoded SAS signatures.

Make split_sas public, change its return type to the public crate::Result<Vec<(String, String)>> (the inner Error variants already convert into crate::Error via the existing From impl, so the two existing internal call sites are unchanged), document it, and re-export it from object_store::azure. Add tests for the empty/? edge cases and the missing-= error path.

What changes are included in this PR?

Plumbing to make split_sas public and additional test coverage. I tried to keep changes minimal - let me know if a broader API change is needed here, instead of a free function export.

Are there any user-facing changes?

No.

`split_sas` parses an Azure Shared Access Signature string into the
`Vec<(String, String)>` query pairs expected by
`AzureCredential::SASToken`. It is what `MicrosoftAzureBuilder` runs
internally when a raw SAS string is supplied via `AzureConfigKey::SasKey`.

Users implementing their own `CredentialProvider<Credential =
AzureCredential>` that fetches SAS tokens at request time (e.g. tokens
refreshed from a secret manager or coordination service) currently have
to reimplement this parser to feed pairs into
`AzureCredential::SASToken`. Reimplementations are easy to get subtly
wrong: in particular, using `form_urlencoded` decodes `+` as space,
which corrupts base64-encoded SAS signatures.

Make `split_sas` public, change its return type to the public
`crate::Result<Vec<(String, String)>>` (the inner `Error` variants
already convert into `crate::Error` via the existing `From` impl, so
the two existing internal call sites are unchanged), document it, and
re-export it from `object_store::azure`. Add tests for the empty/`?`
edge cases and the missing-`=` error path.
Copy link
Copy Markdown
Contributor

@kevinjqliu kevinjqliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose azure::split_sas for custom SAS credential providers

3 participants