-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Storage] Storage Client Options Support Audiences #38438
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
aedf83b
Initial work for Blob Clients to support Audience
amnguye 217f30b
Export API
amnguye 63de00f
Moved BlobAudience to Models; Added Audience support in DataLake; Add…
amnguye 0ad1e64
Added audience support for Shares and Queues; Recorded tests; Cannot …
amnguye 7a267fb
Rerecord failure expected tests
amnguye 6a13de4
Adding default scope after resource id is set; Recorded Share Files t…
amnguye 9864206
Actually removing /.default from tests and correct order of what defa…
amnguye 1c1768c
Merge branch 'main' into feature/storage/aad-audience
amnguye 0d43f24
Trying to resolve CI issues with Audience.Equals(string)
amnguye 4a71620
Merge branch 'main' into feature/storage/aad-audience
amnguye 46c97a2
Attempt to fix CI issues
amnguye e15e073
Cleanup
amnguye 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.ComponentModel; | ||
| using System.Text; | ||
| using Azure.Core; | ||
|
|
||
| namespace Azure.Storage.Blobs | ||
| { | ||
| /// <summary> | ||
| /// Audiences available for Blobs | ||
| /// </summary> | ||
| public readonly partial struct BlobAudience : IEquatable<BlobAudience> | ||
| { | ||
| private readonly string _audience; | ||
|
|
||
| /// <summary> | ||
| /// Intializes new instance of <see cref="BlobAudience"/>. | ||
| /// </summary> | ||
| /// <param name="audience"> | ||
| /// The Azure Active Directory audience to use when forming authorization scopes. | ||
| /// For the Language service, this value corresponds to a URL that identifies the Azure cloud where the resource is located. | ||
| /// For more information: <see href="https://learn.microsoft.com/en-us/azure/storage/blobs/authorize-access-azure-active-directory" />. | ||
| /// </param> | ||
| /// <remarks>Please use one of the static constant members over creating a custom value unless you have specific scenario for doing so.</remarks> | ||
| public BlobAudience(string audience) | ||
| { | ||
| Argument.AssertNotNullOrEmpty(audience, nameof(audience)); | ||
| _audience = audience; | ||
| } | ||
|
|
||
| private const string _publicAudience = "https://storage.azure.com/.default"; | ||
|
|
||
| /// <summary> | ||
| /// Default Audience. Use to acquire a token for authorizing requests to any Azure Storage account | ||
| /// | ||
| /// Resource ID: "https://storage.azure.com/.default ". | ||
| /// | ||
| /// If no audience is specified, this is the default value. | ||
| /// </summary> | ||
| public static BlobAudience PublicAudience { get; } = new(_publicAudience); | ||
|
|
||
| /// <summary> | ||
| /// The service endpoint for a given storage account. | ||
| /// Use this method to acquire a token for authorizing requests to that specific Azure Storage account and service only. | ||
| /// </summary> | ||
| /// <param name="storageAccountName"></param> | ||
| /// <returns></returns> | ||
| public static BlobAudience BlobServiceAccountAudience(string storageAccountName) => new($"https://{storageAccountName}.blob.core.windows.net/.default"); | ||
|
amnguye marked this conversation as resolved.
Outdated
|
||
|
|
||
| /// <inheritdoc /> | ||
| [EditorBrowsable(EditorBrowsableState.Never)] | ||
| public override bool Equals(object obj) => obj is BlobAudience other && Equals(other); | ||
| /// <inheritdoc /> | ||
| public bool Equals(BlobAudience other) => string.Equals(_audience, other._audience, StringComparison.InvariantCultureIgnoreCase); | ||
|
|
||
| /// <inheritdoc /> | ||
| [EditorBrowsable(EditorBrowsableState.Never)] | ||
| public override int GetHashCode() => _audience?.GetHashCode() ?? 0; | ||
| /// <inheritdoc /> | ||
| public override string ToString() => _audience; | ||
|
amnguye marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
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
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.