-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Dynamic User Delegation SAS 101 #53288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
nickliu-msft
wants to merge
12
commits into
Azure:feature/storage/stg101base
Choose a base branch
from
nickliu-msft:feature/storage/DynamicSas
base: feature/storage/stg101base
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 5 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3548404
Changes for Blobs
nickliu-msft 6e896a7
Added fail test
nickliu-msft 3e586c1
Fixes for Blobs
nickliu-msft 8645b02
Export Apis for Blobs
nickliu-msft 443d82c
Added changes for DataLake
nickliu-msft 9e156b4
srh stringToSign change for repeating request headers
nickliu-msft 965888f
remove valdiation/ignore for null/empty
nickliu-msft 0dc2868
changed name of test method
nickliu-msft 49555dd
Changed interface of RequestHeader and RequestQueryParam to be Dictio…
nickliu-msft 0a68277
Removed comment
nickliu-msft 0c15cb8
Added test cases for special characters
nickliu-msft 496b378
pt2
nickliu-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -189,6 +189,18 @@ public class BlobSasBuilder | |
| /// </summary> | ||
| public string DelegatedUserObjectId { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Optional. Custom Request Headers to include in the SAS. Any usage of the SAS must | ||
| /// include these headers and values in the request. A header may have multiple values. | ||
| /// </summary> | ||
| public Dictionary<string, List<string>> RequestHeaders { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Optional. Custom Request Query Parameters to include in the SAS. Any usage of the SAS must | ||
| /// include these query parameters and values in the request. A query parameter may have multiple values. | ||
| /// </summary> | ||
| public Dictionary<string, List<string>> RequestQueryParameters { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="BlobSasBuilder"/> | ||
| /// class. | ||
|
|
@@ -462,6 +474,7 @@ public BlobSasQueryParameters ToSasQueryParameters(UserDelegationKey userDelegat | |
| EnsureState(); | ||
|
|
||
| stringToSign = ToStringToSign(userDelegationKey, accountName); | ||
| Console.WriteLine($"StringToSign = \n{stringToSign}\nEND"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Todo: Remove this Console log and others
nickliu-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| string signature = SasExtensions.ComputeHMACSHA256(userDelegationKey.Value, stringToSign); | ||
|
|
||
|
|
@@ -491,7 +504,9 @@ public BlobSasQueryParameters ToSasQueryParameters(UserDelegationKey userDelegat | |
| authorizedAadObjectId: PreauthorizedAgentObjectId, | ||
| correlationId: CorrelationId, | ||
| encryptionScope: EncryptionScope, | ||
| delegatedUserObjectId: DelegatedUserObjectId); | ||
| delegatedUserObjectId: DelegatedUserObjectId, | ||
| requestHeaders: SasExtensions.ConvertRequestDictToKeyList(RequestHeaders), | ||
| requestQueryParameters: SasExtensions.ConvertRequestDictToKeyList(RequestQueryParameters)); | ||
| return p; | ||
| } | ||
|
|
||
|
|
@@ -501,6 +516,8 @@ private string ToStringToSign(UserDelegationKey userDelegationKey, string accoun | |
| string expiryTime = SasExtensions.FormatTimesForSasSigning(ExpiresOn); | ||
| string signedStart = SasExtensions.FormatTimesForSasSigning(userDelegationKey.SignedStartsOn); | ||
| string signedExpiry = SasExtensions.FormatTimesForSasSigning(userDelegationKey.SignedExpiresOn); | ||
| string canonicalizedSignedRequestHeaders = SasExtensions.FormatRequestHeadersForSasSigning(RequestHeaders); | ||
| string canonicalizedSignedRequestQueryParameters = SasExtensions.FormatRequestQueryParametersForSasSigning(RequestQueryParameters); | ||
|
|
||
| // See http://msdn.microsoft.com/en-us/library/azure/dn140255.aspx | ||
| return string.Join("\n", | ||
|
|
@@ -525,6 +542,8 @@ private string ToStringToSign(UserDelegationKey userDelegationKey, string accoun | |
| Resource, | ||
| Snapshot ?? BlobVersionId, | ||
| EncryptionScope, | ||
| canonicalizedSignedRequestHeaders, | ||
| canonicalizedSignedRequestQueryParameters, | ||
| CacheControl, | ||
| ContentDisposition, | ||
| ContentEncoding, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.