Skip to content
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

[Storage] Renamed PublicAudience to DefaultAudience, Get..Audience to Create..Audience #39083

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,11 @@ internal BlobAppendInfo() { }
private readonly object _dummy;
private readonly int _dummyPrimitive;
public BlobAudience(string value) { throw null; }
public static Azure.Storage.Blobs.Models.BlobAudience PublicAudience { get { throw null; } }
public static Azure.Storage.Blobs.Models.BlobAudience DefaultAudience { get { throw null; } }
public static Azure.Storage.Blobs.Models.BlobAudience CreateBlobServiceAccountAudience(string storageAccountName) { throw null; }
public bool Equals(Azure.Storage.Blobs.Models.BlobAudience other) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object obj) { throw null; }
public static Azure.Storage.Blobs.Models.BlobAudience GetBlobServiceAccountAudience(string storageAccountName) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override int GetHashCode() { throw null; }
public static bool operator ==(Azure.Storage.Blobs.Models.BlobAudience left, Azure.Storage.Blobs.Models.BlobAudience right) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,11 @@ internal BlobAppendInfo() { }
private readonly object _dummy;
private readonly int _dummyPrimitive;
public BlobAudience(string value) { throw null; }
public static Azure.Storage.Blobs.Models.BlobAudience PublicAudience { get { throw null; } }
public static Azure.Storage.Blobs.Models.BlobAudience DefaultAudience { get { throw null; } }
public static Azure.Storage.Blobs.Models.BlobAudience CreateBlobServiceAccountAudience(string storageAccountName) { throw null; }
public bool Equals(Azure.Storage.Blobs.Models.BlobAudience other) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object obj) { throw null; }
public static Azure.Storage.Blobs.Models.BlobAudience GetBlobServiceAccountAudience(string storageAccountName) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override int GetHashCode() { throw null; }
public static bool operator ==(Azure.Storage.Blobs.Models.BlobAudience left, Azure.Storage.Blobs.Models.BlobAudience right) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,11 @@ internal BlobAppendInfo() { }
private readonly object _dummy;
private readonly int _dummyPrimitive;
public BlobAudience(string value) { throw null; }
public static Azure.Storage.Blobs.Models.BlobAudience PublicAudience { get { throw null; } }
public static Azure.Storage.Blobs.Models.BlobAudience DefaultAudience { get { throw null; } }
public static Azure.Storage.Blobs.Models.BlobAudience CreateBlobServiceAccountAudience(string storageAccountName) { throw null; }
public bool Equals(Azure.Storage.Blobs.Models.BlobAudience other) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object obj) { throw null; }
public static Azure.Storage.Blobs.Models.BlobAudience GetBlobServiceAccountAudience(string storageAccountName) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override int GetHashCode() { throw null; }
public static bool operator ==(Azure.Storage.Blobs.Models.BlobAudience left, Azure.Storage.Blobs.Models.BlobAudience right) { throw null; }
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public BlobBaseClient(Uri blobUri, TokenCredential credential, BlobClientOptions
: this(
blobUri,
credential.AsPolicy(
string.IsNullOrEmpty(options?.Audience?.ToString()) ? BlobAudience.PublicAudience.CreateDefaultScope() : options.Audience.Value.CreateDefaultScope(),
string.IsNullOrEmpty(options?.Audience?.ToString()) ? BlobAudience.DefaultAudience.CreateDefaultScope() : options.Audience.Value.CreateDefaultScope(),
options),
options,
storageSharedKeyCredential: null,
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/Azure.Storage.Blobs/src/BlobClientOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ internal HttpPipeline Build(object credentials)
/// <summary>
/// Gets or sets the Audience to use for authentication with Azure Active Directory (AAD). The audience is not considered when using a shared key.
/// </summary>
/// <value>If <c>null</c>, <see cref="BlobAudience.PublicAudience" /> will be assumed.</value>
/// <value>If <c>null</c>, <see cref="BlobAudience.DefaultAudience" /> will be assumed.</value>
public BlobAudience? Audience { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public BlobContainerClient(Uri blobContainerUri, TokenCredential credential, Blo
Argument.AssertNotNull(blobContainerUri, nameof(blobContainerUri));
_uri = blobContainerUri;

string audienceScope = string.IsNullOrEmpty(options?.Audience?.ToString()) ? BlobAudience.PublicAudience.CreateDefaultScope() : options.Audience.Value.CreateDefaultScope();
string audienceScope = string.IsNullOrEmpty(options?.Audience?.ToString()) ? BlobAudience.DefaultAudience.CreateDefaultScope() : options.Audience.Value.CreateDefaultScope();

_authenticationPolicy = credential.AsPolicy(audienceScope, options);
options ??= new BlobClientOptions();
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public BlobServiceClient(Uri serviceUri, TokenCredential credential, BlobClientO
: this(
serviceUri,
credential.AsPolicy(
string.IsNullOrEmpty(options?.Audience?.ToString()) ? BlobAudience.PublicAudience.CreateDefaultScope() : options.Audience.Value.CreateDefaultScope(),
string.IsNullOrEmpty(options?.Audience?.ToString()) ? BlobAudience.DefaultAudience.CreateDefaultScope() : options.Audience.Value.CreateDefaultScope(),
options),
credential,
options ?? new BlobClientOptions())
Expand Down
6 changes: 3 additions & 3 deletions sdk/storage/Azure.Storage.Blobs/src/Models/BlobAudience.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public BlobAudience(string value)
_value = value;
}

private const string _publicAudience = "https://storage.azure.com/";
private const string _defaultAudience = "https://storage.azure.com/";

/// <summary>
/// Default Audience. Use to acquire a token for authorizing requests to any Azure Storage account
Expand All @@ -38,7 +38,7 @@ public BlobAudience(string value)
///
/// If no audience is specified, this is the default value.
/// </summary>
public static BlobAudience PublicAudience { get; } = new(_publicAudience);
public static BlobAudience DefaultAudience { get; } = new(_defaultAudience);

/// <summary>
/// The service endpoint for a given storage account.
Expand All @@ -48,7 +48,7 @@ public BlobAudience(string value)
/// The storage account name used to populate the service endpoint.
/// </param>
/// <returns></returns>
public static BlobAudience GetBlobServiceAccountAudience(string storageAccountName) => new($"https://{storageAccountName}.blob.core.windows.net/");
public static BlobAudience CreateBlobServiceAccountAudience(string storageAccountName) => new($"https://{storageAccountName}.blob.core.windows.net/");

/// <summary> Determines if two <see cref="BlobAudience"/> values are the same. </summary>
public static bool operator ==(BlobAudience left, BlobAudience right) => left.Equals(right);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public async Task Ctor_DefaultAudience()
await blob.CreateIfNotExistsAsync();

// Act - Create new blob client with the OAuth Credential and Audience
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.PublicAudience);
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.DefaultAudience);

BlobUriBuilder uriBuilder = new BlobUriBuilder(new Uri(Tenants.TestConfigOAuth.BlobServiceEndpoint))
{
Expand Down Expand Up @@ -222,7 +222,7 @@ public async Task Ctor_StorageAccountAudience()
await blob.CreateIfNotExistsAsync();

// Act - Create new blob client with the OAuth Credential and Audience
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.GetBlobServiceAccountAudience(test.Container.AccountName));
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.CreateBlobServiceAccountAudience(test.Container.AccountName));

BlobUriBuilder uriBuilder = new BlobUriBuilder(new Uri(Tenants.TestConfigOAuth.BlobServiceEndpoint))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public async Task Ctor_DefaultAudience()
}

// Act - Create new blob client with the OAuth Credential and Audience
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.PublicAudience);
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.DefaultAudience);

BlobUriBuilder uriBuilder = new BlobUriBuilder(new Uri(Tenants.TestConfigOAuth.BlobServiceEndpoint))
{
Expand Down Expand Up @@ -320,7 +320,7 @@ public async Task Ctor_StorageAccountAudience()
}

// Act - Create new blob client with the OAuth Credential and Audience
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.GetBlobServiceAccountAudience(test.Container.AccountName));
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.CreateBlobServiceAccountAudience(test.Container.AccountName));

BlobUriBuilder uriBuilder = new BlobUriBuilder(new Uri(Tenants.TestConfigOAuth.BlobServiceEndpoint))
{
Expand Down Expand Up @@ -352,7 +352,7 @@ public async Task Ctor_AudienceError()
}

// Act - Create new blob client with the OAuth Credential and Audience
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.PublicAudience);
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.DefaultAudience);

BlobUriBuilder uriBuilder = new BlobUriBuilder(new Uri(Tenants.TestConfigOAuth.BlobServiceEndpoint))
{
Expand Down
4 changes: 2 additions & 2 deletions sdk/storage/Azure.Storage.Blobs/tests/BlobClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public async Task Ctor_DefaultAudience()
}

// Act - Create new blob client with the OAuth Credential and Audience
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.PublicAudience);
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.DefaultAudience);

BlobUriBuilder uriBuilder = new BlobUriBuilder(new Uri(Tenants.TestConfigOAuth.BlobServiceEndpoint))
{
Expand Down Expand Up @@ -272,7 +272,7 @@ public async Task Ctor_StorageAccountAudience()
}

// Act - Create new blob client with the OAuth Credential and Audience
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.GetBlobServiceAccountAudience(test.Container.AccountName));
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.CreateBlobServiceAccountAudience(test.Container.AccountName));

BlobUriBuilder uriBuilder = new BlobUriBuilder(new Uri(Tenants.TestConfigOAuth.BlobServiceEndpoint))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public async Task Ctor_DefaultAudience()
await using DisposingContainer test = await GetTestContainerAsync();

// Act - Create new blob client with the OAuth Credential and Audience
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.PublicAudience);
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.DefaultAudience);

BlobUriBuilder uriBuilder = new BlobUriBuilder(new Uri(Tenants.TestConfigOAuth.BlobServiceEndpoint))
{
Expand Down Expand Up @@ -384,7 +384,7 @@ public async Task Ctor_StorageAccountAudience()
await using DisposingContainer test = await GetTestContainerAsync();

// Act - Create new blob client with the OAuth Credential and Audience
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.GetBlobServiceAccountAudience(test.Container.AccountName));
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.CreateBlobServiceAccountAudience(test.Container.AccountName));

BlobUriBuilder uriBuilder = new BlobUriBuilder(new Uri(Tenants.TestConfigOAuth.BlobServiceEndpoint))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public async Task Ctor_DefaultAudience()
await blob.CreateIfNotExistsAsync(Constants.KB);

// Act - Create new blob client with the OAuth Credential and Audience
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.PublicAudience);
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.DefaultAudience);

BlobUriBuilder uriBuilder = new BlobUriBuilder(new Uri(Tenants.TestConfigOAuth.BlobServiceEndpoint))
{
Expand Down Expand Up @@ -212,7 +212,7 @@ public async Task Ctor_StorageAccountAudience()
await blob.CreateIfNotExistsAsync(Constants.KB);

// Act - Create new blob client with the OAuth Credential and Audience
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.GetBlobServiceAccountAudience(test.Container.AccountName));
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.CreateBlobServiceAccountAudience(test.Container.AccountName));

BlobUriBuilder uriBuilder = new BlobUriBuilder(new Uri(Tenants.TestConfigOAuth.BlobServiceEndpoint))
{
Expand Down
4 changes: 2 additions & 2 deletions sdk/storage/Azure.Storage.Blobs/tests/ServiceClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public void Ctor_With_Sas_Does_Not_Reorder_Services()
public async Task Ctor_DefaultAudience()
{
// Act - Create new blob client with the OAuth Credential and Audience
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.PublicAudience);
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.DefaultAudience);

BlobServiceClient aadService = InstrumentClient(new BlobServiceClient(
new Uri(Tenants.TestConfigOAuth.BlobServiceEndpoint),
Expand Down Expand Up @@ -217,7 +217,7 @@ public async Task Ctor_StorageAccountAudience()
BlobUriBuilder uriBuilder = new BlobUriBuilder(new Uri(Tenants.TestConfigOAuth.BlobServiceEndpoint));

// Act - Create new blob client with the OAuth Credential and Audience
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.GetBlobServiceAccountAudience(uriBuilder.AccountName));
BlobClientOptions options = GetOptionsWithAudience(BlobAudience.CreateBlobServiceAccountAudience(uriBuilder.AccountName));

BlobServiceClient aadService = InstrumentClient(new BlobServiceClient(
new Uri(Tenants.TestConfigOAuth.BlobServiceEndpoint),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,8 @@ public DataLakeAnalyticsLogging() { }
private readonly object _dummy;
private readonly int _dummyPrimitive;
public DataLakeAudience(string value) { throw null; }
public static Azure.Storage.Files.DataLake.Models.DataLakeAudience PublicAudience { get { throw null; } }
public static Azure.Storage.Files.DataLake.Models.DataLakeAudience DataLakeServiceAccountAudience(string storageAccountName) { throw null; }
public static Azure.Storage.Files.DataLake.Models.DataLakeAudience DefaultAudience { get { throw null; } }
public static Azure.Storage.Files.DataLake.Models.DataLakeAudience CreateDataLakeServiceAccountAudience(string storageAccountName) { throw null; }
public bool Equals(Azure.Storage.Files.DataLake.Models.DataLakeAudience other) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object obj) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,8 @@ public DataLakeAnalyticsLogging() { }
private readonly object _dummy;
private readonly int _dummyPrimitive;
public DataLakeAudience(string value) { throw null; }
public static Azure.Storage.Files.DataLake.Models.DataLakeAudience PublicAudience { get { throw null; } }
public static Azure.Storage.Files.DataLake.Models.DataLakeAudience DataLakeServiceAccountAudience(string storageAccountName) { throw null; }
public static Azure.Storage.Files.DataLake.Models.DataLakeAudience DefaultAudience { get { throw null; } }
public static Azure.Storage.Files.DataLake.Models.DataLakeAudience CreateDataLakeServiceAccountAudience(string storageAccountName) { throw null; }
public bool Equals(Azure.Storage.Files.DataLake.Models.DataLakeAudience other) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object obj) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ internal HttpPipeline Build(object credentials)
/// <summary>
/// Gets or sets the Audience to use for authentication with Azure Active Directory (AAD). The audience is not considered when using a shared key.
/// </summary>
/// <value>If <c>null</c>, <see cref="DataLakeAudience.PublicAudience" /> will be assumed.</value>
/// <value>If <c>null</c>, <see cref="DataLakeAudience.DefaultAudience" /> will be assumed.</value>
public DataLakeAudience? Audience { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public DataLakeDirectoryClient(Uri directoryUri, TokenCredential credential, Dat
: this(
directoryUri,
credential.AsPolicy(
string.IsNullOrEmpty(options?.Audience?.ToString()) ? DataLakeAudience.PublicAudience.CreateDefaultScope() : options.Audience.Value.CreateDefaultScope(),
string.IsNullOrEmpty(options?.Audience?.ToString()) ? DataLakeAudience.DefaultAudience.CreateDefaultScope() : options.Audience.Value.CreateDefaultScope(),
options),
options,
tokenCredential: credential)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public DataLakeFileClient(Uri fileUri, TokenCredential credential, DataLakeClien
: this(
fileUri,
credential.AsPolicy(
string.IsNullOrEmpty(options?.Audience?.ToString()) ? DataLakeAudience.PublicAudience.CreateDefaultScope() : options.Audience.Value.CreateDefaultScope(),
string.IsNullOrEmpty(options?.Audience?.ToString()) ? DataLakeAudience.DefaultAudience.CreateDefaultScope() : options.Audience.Value.CreateDefaultScope(),
options),
options,
credential)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public DataLakeFileSystemClient(Uri fileSystemUri, TokenCredential credential, D
: this(
fileSystemUri,
credential.AsPolicy(
string.IsNullOrEmpty(options?.Audience?.ToString()) ? DataLakeAudience.PublicAudience.CreateDefaultScope() : options.Audience.Value.CreateDefaultScope(),
string.IsNullOrEmpty(options?.Audience?.ToString()) ? DataLakeAudience.DefaultAudience.CreateDefaultScope() : options.Audience.Value.CreateDefaultScope(),
options),
options,
storageSharedKeyCredential: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ public DataLakePathClient(Uri pathUri, TokenCredential credential, DataLakeClien
: this(
pathUri,
credential.AsPolicy(
string.IsNullOrEmpty(options?.Audience?.ToString()) ? DataLakeAudience.PublicAudience.CreateDefaultScope() : options.Audience.Value.CreateDefaultScope(),
string.IsNullOrEmpty(options?.Audience?.ToString()) ? DataLakeAudience.DefaultAudience.CreateDefaultScope() : options.Audience.Value.CreateDefaultScope(),
options),
options,
storageSharedKeyCredential: null,
Expand Down
Loading
Loading