Fix service bus queue SAS token generation #1518
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The PR to standardize HMAC implementation (#1473) introduced an issue in generating service bus queue SAS tokens.
The standard implementation in
azure_core::auth::hmac
assumes the signing key is thebase64::decoded
of the key passed as an argument:azure-sdk-for-rust/sdk/core/src/hmac.rs
Line 12 in a32e411
On the
service_bus/queue_client
side it is used like the following, which means it'll be decoded inside the hmac function.azure-sdk-for-rust/sdk/messaging_servicebus/src/service_bus/mod.rs
Line 67 in a32e411
However, from the version before the merge, I gathered the key needs to be used verbatim as bytes:
azure-sdk-for-rust/sdk/messaging_servicebus/src/service_bus/mod.rs
Line 67 in 346330b
Tested this using this example and confirmed that the fix works. If this is not the direction / style of fix you want, I'd be happy to rework it to make it more suitable.
I also wanted to add a few unit tests for the SAS token generation but this would need a time-mocking library so I wanted to check before changing the code further.