Skip to content

Commit

Permalink
Drop ADAL to unblock pipeline (#6687)
Browse files Browse the repository at this point in the history
* init

* update

* revert one test

* revert one test

* add compatbaseline
  • Loading branch information
Danieladu authored Sep 6, 2023
1 parent 501ddca commit 2d09ba8
Show file tree
Hide file tree
Showing 20 changed files with 18 additions and 883 deletions.
9 changes: 8 additions & 1 deletion ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# These types are no longer supported in Microsoft.Bot.Builder.Azure:
TypesMustExist : Type 'Microsoft.Bot.Builder.Azure.CosmosDbCustomClientOptions' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'Microsoft.Bot.Builder.Azure.CosmosDbStorage' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'Microsoft.Bot.Builder.Azure.CosmosDbStorageOptions' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'Microsoft.Bot.Builder.Azure.CosmosDbStorageOptions' does not exist in the implementation but it does exist in the contract.

TypesMustExist : Type 'Microsoft.Bot.Connector.Authentication.AdalAuthenticator' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'Microsoft.Bot.Connector.Authentication.AppCredentials.BuildAuthenticator()' does not exist in the implementation but it does exist in the contract.
CannotAddAbstractMembers : Member 'Microsoft.Bot.Connector.Authentication.AppCredentials.BuildIAuthenticator()' is abstract in the implementation but is missing in the contract.
MembersMustExist : Member 'Microsoft.Bot.Connector.Authentication.CertificateAppCredentials..ctor(Microsoft.IdentityModel.Clients.ActiveDirectory.ClientAssertionCertificate, System.String, System.Net.Http.HttpClient, Microsoft.Extensions.Logging.ILogger)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'Microsoft.Bot.Connector.Authentication.CertificateAppCredentials.BuildAuthenticator()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'Microsoft.Bot.Connector.Authentication.MicrosoftAppCredentials.BuildAuthenticator()' does not exist in the implementation but it does exist in the contract.
337 changes: 0 additions & 337 deletions libraries/Microsoft.Bot.Connector/Authentication/AdalAuthenticator.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -213,27 +213,11 @@ public async Task<string> GetTokenAsync(bool forceRefresh = false)
return token.AccessToken;
}

/// <summary>
/// Builds the lazy <see cref="AdalAuthenticator" /> to be used for token acquisition.
/// </summary>
/// <returns>A lazy <see cref="AdalAuthenticator"/>.</returns>
[Obsolete("This method is deprecated. Use BuildIAuthenticator instead.", false)]
protected abstract Lazy<AdalAuthenticator> BuildAuthenticator();

/// <summary>
/// Builds the lazy <see cref="IAuthenticator" /> to be used for token acquisition.
/// </summary>
/// <returns>A lazy <see cref="IAuthenticator"/>.</returns>
protected virtual Lazy<IAuthenticator> BuildIAuthenticator()
{
return new Lazy<IAuthenticator>(
() =>
{
var lazyAuthenticator = BuildAuthenticator();
return lazyAuthenticator.Value;
},
LazyThreadSafetyMode.ExecutionAndPublication);
}
protected abstract Lazy<IAuthenticator> BuildIAuthenticator();

private bool ShouldSetToken()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Clients.ActiveDirectory;

namespace Microsoft.Bot.Connector.Authentication
{
Expand All @@ -15,7 +14,6 @@ namespace Microsoft.Bot.Connector.Authentication
/// </summary>
public class CertificateAppCredentials : AppCredentials
{
private readonly ClientAssertionCertificate adalClientCertificate;
private readonly X509Certificate2 clientCertificate;
private readonly bool sendX5c;

Expand Down Expand Up @@ -81,58 +79,6 @@ public CertificateAppCredentials(X509Certificate2 clientCertificate, bool sendX5
MicrosoftAppId = appId;
}

/// <summary>
/// Initializes a new instance of the <see cref="CertificateAppCredentials"/> class.
/// </summary>
/// <param name="clientCertificate">Client certificate to be presented for authentication.</param>
/// <param name="channelAuthTenant">Optional. The oauth token tenant.</param>
/// <param name="customHttpClient">Optional <see cref="HttpClient"/> to be used when acquiring tokens.</param>
/// <param name="logger">Optional <see cref="ILogger"/> to gather telemetry data while acquiring and managing credentials.</param>
public CertificateAppCredentials(ClientAssertionCertificate clientCertificate, string channelAuthTenant = null, HttpClient customHttpClient = null, ILogger logger = null)
: this(clientCertificate, false, channelAuthTenant, customHttpClient, logger)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="CertificateAppCredentials"/> class.
/// </summary>
/// <param name="clientCertificate">Client certificate to be presented for authentication.</param>
/// <param name="sendX5c">This parameter, if true, enables application developers to achieve easy certificates roll-over in Azure AD: setting this parameter to true will send the public certificate to Azure AD along with the token request, so that Azure AD can use it to validate the subject name based on a trusted issuer policy. </param>
/// <param name="channelAuthTenant">Optional. The oauth token tenant.</param>
/// <param name="customHttpClient">Optional <see cref="HttpClient"/> to be used when acquiring tokens.</param>
/// <param name="logger">Optional <see cref="ILogger"/> to gather telemetry data while acquiring and managing credentials.</param>
public CertificateAppCredentials(ClientAssertionCertificate clientCertificate, bool sendX5c, string channelAuthTenant = null, HttpClient customHttpClient = null, ILogger logger = null)
: base(channelAuthTenant, customHttpClient, logger)
{
if (clientCertificate == null)
{
throw new ArgumentNullException(nameof(clientCertificate));
}

this.sendX5c = sendX5c;
this.clientCertificate = clientCertificate.Certificate;
MicrosoftAppId = clientCertificate.ClientId;
adalClientCertificate = clientCertificate;
}

/// <summary>
/// Builds the lazy <see cref="AdalAuthenticator" /> to be used for token acquisition.
/// </summary>
/// <returns>A lazy <see cref="AdalAuthenticator"/>.</returns>
[Obsolete("This method is deprecated. Use BuildIAuthenticator instead.", false)]
protected override Lazy<AdalAuthenticator> BuildAuthenticator()
{
return new Lazy<AdalAuthenticator>(
() =>
new AdalAuthenticator(
adalClientCertificate,
sendX5c,
new OAuthConfiguration() { Authority = OAuthEndpoint, ValidateAuthority = ValidateAuthority, Scope = OAuthScope },
CustomHttpClient,
Logger),
LazyThreadSafetyMode.ExecutionAndPublication);
}

/// <inheritdoc/>
protected override Lazy<IAuthenticator> BuildIAuthenticator()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
namespace Microsoft.Bot.Connector.Authentication
{
/// <summary>
/// HttpClientFactory that always returns the same HttpClient instance for ADAL AcquireTokenAsync calls.
/// HttpClientFactory that always returns the same HttpClient instance for AcquireTokenAsync calls.
/// </summary>
internal class ConstantHttpClientFactory : IdentityModel.Clients.ActiveDirectory.IHttpClientFactory, IMsalHttpClientFactory
internal class ConstantHttpClientFactory : IMsalHttpClientFactory
{
private readonly HttpClient httpClient;

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,6 @@ namespace Microsoft.Bot.Connector.Authentication
/// </summary>
public class ManagedIdentityAppCredentials : AppCredentials
{
/// <summary>
/// Initializes a new instance of the <see cref="ManagedIdentityAppCredentials"/> class.
/// Managed Identity for AAD credentials auth and caching.
/// </summary>
/// <param name="appId">Client ID for the managed identity assigned to the bot.</param>
/// <param name="oAuthScope">The scope for the token.</param>
/// <param name="tokenProviderFactory">The JWT token provider factory to use.</param>
/// <param name="customHttpClient">Optional <see cref="HttpClient"/> to be used when acquiring tokens.</param>
/// <param name="logger">Optional <see cref="ILogger"/> to gather telemetry data while acquiring and managing credentials.</param>
[Obsolete("This method is deprecated, the IJwtTokenProviderFactory argument is now redundant. Use the overload without this argument.", false)]
public ManagedIdentityAppCredentials(string appId, string oAuthScope, IJwtTokenProviderFactory tokenProviderFactory, HttpClient customHttpClient = null, ILogger logger = null)
: this(appId, oAuthScope, customHttpClient, logger)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="ManagedIdentityAppCredentials"/> class.
/// Managed Identity for AAD credentials auth and caching.
Expand All @@ -47,14 +32,6 @@ public ManagedIdentityAppCredentials(string appId, string oAuthScope, HttpClient
MicrosoftAppId = appId;
}

/// <inheritdoc/>
[Obsolete("This method is deprecated. Use BuildIAuthenticator instead.", false)]
protected override Lazy<AdalAuthenticator> BuildAuthenticator()
{
// Should not be called, legacy
throw new NotImplementedException();
}

/// <inheritdoc/>
protected override Lazy<IAuthenticator> BuildIAuthenticator()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,6 @@ public class ManagedIdentityAuthenticator : IAuthenticator
private readonly ILogger _logger;
private readonly IConfidentialClientApplication _clientApplication;

/// <summary>
/// Initializes a new instance of the <see cref="ManagedIdentityAuthenticator"/> class.
/// </summary>
/// <param name="appId">Client id for the managed identity to be used for acquiring tokens.</param>
/// <param name="resource">Resource for which to acquire the token.</param>
/// <param name="tokenProviderFactory">The JWT token provider factory to use.</param>
/// <param name="customHttpClient">A customized instance of the HttpClient class.</param>
/// <param name="logger">The type used to perform logging.</param>
[Obsolete("This method is deprecated, the IJwtTokenProviderFactory argument is now redundant. Use the overload without this argument.", false)]
public ManagedIdentityAuthenticator(string appId, string resource, IJwtTokenProviderFactory tokenProviderFactory, HttpClient customHttpClient = null, ILogger logger = null)
: this(appId, resource, customHttpClient, logger)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="ManagedIdentityAuthenticator"/> class.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,6 @@ public class ManagedIdentityServiceClientCredentialsFactory : ServiceClientCrede
private readonly HttpClient _httpClient;
private readonly ILogger _logger;

/// <summary>
/// Initializes a new instance of the <see cref="ManagedIdentityServiceClientCredentialsFactory"/> class.
/// </summary>
/// <param name="appId">Client ID for the managed identity assigned to the bot.</param>
/// <param name="tokenProviderFactory">The JWT token provider factory to use.</param>
/// <param name="httpClient">A custom httpClient to use.</param>
/// <param name="logger">A logger instance to use.</param>
[Obsolete("This method is deprecated, the IJwtTokenProviderFactory argument is now redundant. Use the overload without this argument.", false)]
public ManagedIdentityServiceClientCredentialsFactory(string appId, IJwtTokenProviderFactory tokenProviderFactory, HttpClient httpClient = null, ILogger logger = null)
: this(appId, httpClient, logger)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="ManagedIdentityServiceClientCredentialsFactory"/> class.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Net.Http;
using System.Threading;
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Clients.ActiveDirectory;

namespace Microsoft.Bot.Connector.Authentication
{
Expand Down Expand Up @@ -134,23 +133,6 @@ public MicrosoftAppCredentials(string appId, string password, string channelAuth
/// </value>
public string MicrosoftAppPassword { get; set; }

/// <summary>
/// Builds the lazy <see cref="AdalAuthenticator" /> to be used for token acquisition.
/// </summary>
/// <returns>A lazy <see cref="AdalAuthenticator"/>.</returns>
[Obsolete("This method is deprecated. Use BuildIAuthenticator instead.", false)]
protected override Lazy<AdalAuthenticator> BuildAuthenticator()
{
return new Lazy<AdalAuthenticator>(
() =>
new AdalAuthenticator(
new ClientCredential(MicrosoftAppId, MicrosoftAppPassword),
new OAuthConfiguration() { Authority = OAuthEndpoint, ValidateAuthority = ValidateAuthority, Scope = OAuthScope },
this.CustomHttpClient,
this.Logger),
LazyThreadSafetyMode.ExecutionAndPublication);
}

/// <inheritdoc/>
protected override Lazy<IAuthenticator> BuildIAuthenticator()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,6 @@ async Task<AuthenticatorResult> IAuthenticator.GetTokenAsync(bool forceRefresh)
return result;
}

/// <inheritdoc/>
[Obsolete("This method is deprecated. Use BuildIAuthenticator instead.", false)]
protected override Lazy<AdalAuthenticator> BuildAuthenticator()
{
throw new NotImplementedException();
}

/// <inheritdoc/>
protected override Lazy<IAuthenticator> BuildIAuthenticator()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.6.1" />
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="2.1.0" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.50.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ public MockAppCredentials(string channelAuthTenant = null, HttpClient customHttp
: base(channelAuthTenant, customHttpClient, logger)
{
}

[Obsolete("This method is deprecated. Use BuildIAuthenticator instead.", false)]
protected override Lazy<AdalAuthenticator> BuildAuthenticator()

protected override Lazy<IAuthenticator> BuildIAuthenticator()
{
return new Lazy<AdalAuthenticator>();
throw new NotImplementedException();
}
}
}
Loading

0 comments on commit 2d09ba8

Please sign in to comment.