-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using Azure.Core; | ||
|
@@ -141,20 +141,18 @@ options.Credential is not null | |
ChannelCredentials.SecureSsl : | ||
ChannelCredentials.Insecure; | ||
return GrpcChannel.ForAddress(endpoint, new GrpcChannelOptions | ||
{ | ||
// The same credential is being used for all operations. | ||
// https://learn.microsoft.com/aspnet/core/grpc/authn-and-authz#set-the-bearer-token-with-callcredentials | ||
Credentials = ChannelCredentials.Create(channelCreds, managedBackendCreds), | ||
|
||
return GrpcChannel.ForAddress(endpoint, new GrpcChannelOptions | ||
{ | ||
// The same credential is being used for all operations. | ||
// https://learn.microsoft.com/aspnet/core/grpc/authn-and-authz#set-the-bearer-token-with-callcredentials | ||
Credentials = ChannelCredentials.Create(channelCreds, managedBackendCreds), | ||
|
||
// TODO: This is not appropriate for use in production settings. Setting this to true should | ||
// only be done for local testing. We should hide this setting behind some kind of flag. | ||
UnsafeUseInsecureChannelCallCredentials = true, | ||
}); | ||
// TODO: This is not appropriate for use in production settings. Setting this to true should | ||
// only be done for local testing. We should hide this setting behind some kind of flag. | ||
UnsafeUseInsecureChannelCallCredentials = true, | ||
}); | ||
} | ||
|
||
static ArgumentException RequiredOptionMissing(string optionName) | ||
static Exception RequiredOptionMissing(string optionName) | ||
Check warning on line 155 in src/Extensions/Azure/DurableTaskSchedulerExtensions.cs GitHub Actions / Analyze (csharp)
Check warning on line 155 in src/Extensions/Azure/DurableTaskSchedulerExtensions.cs GitHub Actions / build
|
||
{ | ||
return new ArgumentException(message: $"Required option '{optionName}' was not provided."); | ||
} | ||
|
@@ -181,4 +179,4 @@ public async Task<AccessToken> GetTokenAsync(CancellationToken cancellationToken | |
return this.token.Value; | ||
} | ||
} | ||
} | ||
} | ||
Check warning on line 182 in src/Extensions/Azure/DurableTaskSchedulerExtensions.cs GitHub Actions / Analyze (csharp)
Check warning on line 182 in src/Extensions/Azure/DurableTaskSchedulerExtensions.cs GitHub Actions / build
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
// Licensed under the MIT License. | ||
Check warning on line 2 in src/Extensions/Azure/DurableTaskSchedulerOptions.cs GitHub Actions / Analyze (csharp)
Check warning on line 2 in src/Extensions/Azure/DurableTaskSchedulerOptions.cs GitHub Actions / build
|
||
|
||
using System.Globalization; | ||
using Azure.Core; | ||
|
@@ -15,9 +15,6 @@ public class DurableTaskSchedulerOptions | |
/// <summary> | ||
/// Initializes a new instance of the <see cref="DurableTaskSchedulerOptions"/> class. | ||
/// </summary> | ||
/// <param name="endpointAddress">The endpoint address of the Durable Task Scheduler service.</param> | ||
/// <param name="taskHubName">The name of the task hub to connect to.</param> | ||
/// <param name="credential">The credential to use for authentication, or null for no authentication.</param> | ||
internal DurableTaskSchedulerOptions(string endpointAddress, string taskHubName, TokenCredential? credential = null) | ||
Check warning on line 18 in src/Extensions/Azure/DurableTaskSchedulerOptions.cs GitHub Actions / Analyze (csharp)
Check warning on line 18 in src/Extensions/Azure/DurableTaskSchedulerOptions.cs GitHub Actions / Analyze (csharp)
Check warning on line 18 in src/Extensions/Azure/DurableTaskSchedulerOptions.cs GitHub Actions / Analyze (csharp)
Check warning on line 18 in src/Extensions/Azure/DurableTaskSchedulerOptions.cs GitHub Actions / build
Check warning on line 18 in src/Extensions/Azure/DurableTaskSchedulerOptions.cs GitHub Actions / build
Check warning on line 18 in src/Extensions/Azure/DurableTaskSchedulerOptions.cs GitHub Actions / build
|
||
{ | ||
this.EndpointAddress = endpointAddress ?? throw new ArgumentNullException(nameof(endpointAddress)); | ||
|
@@ -77,6 +74,7 @@ public static DurableTaskSchedulerOptions FromConnectionString( | |
// "Endpoint=https://myaccount.westus3.durabletask.io/;Authentication=ManagedIdentity;ClientID=00000000-0000-0000-0000-000000000000;TaskHubName=th01" | ||
// "Endpoint=https://myaccount.westus3.durabletask.io/;Authentication=DefaultAzure;TaskHubName=th01" | ||
// "Endpoint=https://myaccount.westus3.durabletask.io/;Authentication=None;TaskHubName=th01" (undocumented and only intended for local testing) | ||
Check warning on line 76 in src/Extensions/Azure/DurableTaskSchedulerOptions.cs GitHub Actions / Analyze (csharp)
Check warning on line 76 in src/Extensions/Azure/DurableTaskSchedulerOptions.cs GitHub Actions / build
|
||
|
||
string endpointAddress = connectionString.Endpoint; | ||
|
||
if (!endpointAddress.Contains("://")) | ||
|
@@ -86,6 +84,7 @@ public static DurableTaskSchedulerOptions FromConnectionString( | |
} | ||
|
||
string authType = connectionString.Authentication; | ||
|
||
TokenCredential? credential; | ||
|
||
// Parse the supported auth types, in a case-insensitive way and without spaces | ||
|
@@ -160,4 +159,4 @@ public static DurableTaskSchedulerOptions FromConnectionString( | |
DurableTaskSchedulerOptions options = new(endpointAddress, connectionString.TaskHubName, credential); | ||
return options; | ||
} | ||
} | ||
} | ||
Check warning on line 162 in src/Extensions/Azure/DurableTaskSchedulerOptions.cs GitHub Actions / Analyze (csharp)
Check warning on line 162 in src/Extensions/Azure/DurableTaskSchedulerOptions.cs GitHub Actions / build
|