Skip to content
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 @@ -95,6 +95,10 @@ public static ConfidentialClientApplicationBuilder Create(string clientId)
/// <remarks>
/// You should use certificates with a private key size of at least 2048 bytes. Future versions of this library might reject certificates with smaller keys.
/// Does not send the certificate (as x5c parameter) with the request by default.
/// This overload captures the supplied certificate when this method is called. When the certificate or private-key handle
/// is managed externally and may rotate or become invalid, use
/// <see cref="Extensibility.ConfidentialClientApplicationBuilderExtensions.WithCertificate(ConfidentialClientApplicationBuilder, Func{AssertionRequestOptions, Task{X509Certificate2}}, CertificateOptions)"/>
/// to resolve the current certificate before each network token request.
/// </remarks>
public ConfidentialClientApplicationBuilder WithCertificate(X509Certificate2 certificate)
{
Expand All @@ -113,7 +117,13 @@ public ConfidentialClientApplicationBuilder WithCertificate(X509Certificate2 cer
/// </summary>
/// <param name="certificate">The X509 certificate used as credentials to prove the identity of the application to Azure AD.</param>
/// <param name="sendX5C">To send X5C with every request or not. The default is <c>false</c></param>
/// <remarks>You should use certificates with a private key size of at least 2048 bytes. Future versions of this library might reject certificates with smaller keys. </remarks>
/// <remarks>
/// You should use certificates with a private key size of at least 2048 bytes. Future versions of this library might reject certificates with smaller keys.
/// This overload captures the supplied certificate when this method is called. When the certificate or private-key handle
/// is managed externally and may rotate or become invalid, use
/// <see cref="Extensibility.ConfidentialClientApplicationBuilderExtensions.WithCertificate(ConfidentialClientApplicationBuilder, Func{AssertionRequestOptions, Task{X509Certificate2}}, CertificateOptions)"/>
/// to resolve the current certificate before each network token request.
/// </remarks>
public ConfidentialClientApplicationBuilder WithCertificate(X509Certificate2 certificate, bool sendX5C)
{
if (certificate == null)
Expand Down Expand Up @@ -143,7 +153,13 @@ public ConfidentialClientApplicationBuilder WithCertificate(X509Certificate2 cer
/// </summary>
/// <param name="certificate">The X509 certificate used as credentials to prove the identity of the application to Azure AD.</param>
/// <param name="certificateOptions">Configuration options for certificate handling. See <see cref="CertificateOptions"/> for more information.</param>
/// <remarks>You should use certificates with a private key size of at least 2048 bytes. Future versions of this library might reject certificates with smaller keys. </remarks>
/// <remarks>
/// You should use certificates with a private key size of at least 2048 bytes. Future versions of this library might reject certificates with smaller keys.
/// This overload captures the supplied certificate when this method is called. When the certificate or private-key handle
/// is managed externally and may rotate or become invalid, use
/// <see cref="Extensibility.ConfidentialClientApplicationBuilderExtensions.WithCertificate(ConfidentialClientApplicationBuilder, Func{AssertionRequestOptions, Task{X509Certificate2}}, CertificateOptions)"/>
/// to resolve the current certificate before each network token request.
/// </remarks>
public ConfidentialClientApplicationBuilder WithCertificate(X509Certificate2 certificate, CertificateOptions certificateOptions)
{
if (certificate == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public static ConfidentialClientApplicationBuilder WithAppTokenProvider(
/// and this method are configured.
/// </exception>
/// <remarks>
/// <para>Use this overload when the certificate or private-key handle is managed externally and may rotate or become invalid.
/// The callback should return the current usable certificate and private-key handle for each network token request.</para>
/// <para>This method cannot be used together with <see cref="ConfidentialClientApplicationBuilder.WithCertificate(X509Certificate2)"/>.</para>
/// <para>The callback is not invoked when tokens are retrieved from cache, only for network calls.</para>
/// <para>The certificate returned by the callback will be used to sign the client assertion (JWT) for that token request.</para>
Expand All @@ -62,8 +64,6 @@ public static ConfidentialClientApplicationBuilder WithCertificate(
Func<AssertionRequestOptions, Task<X509Certificate2>> certificateProvider,
CertificateOptions certificateOptions)
{
builder.ValidateUseOfExperimentalFeature();

if (certificateProvider == null)
{
throw new ArgumentNullException(nameof(certificateProvider));
Expand Down Expand Up @@ -125,8 +125,6 @@ public static ConfidentialClientApplicationBuilder OnMsalServiceFailure(
this ConfidentialClientApplicationBuilder builder,
Func<AssertionRequestOptions, ExecutionResult, Task<bool>> onMsalServiceFailure)
{
builder.ValidateUseOfExperimentalFeature();

if (onMsalServiceFailure == null)
throw new ArgumentNullException(nameof(onMsalServiceFailure));

Expand Down Expand Up @@ -179,8 +177,6 @@ public static ConfidentialClientApplicationBuilder OnCompletion(
this ConfidentialClientApplicationBuilder builder,
Func<AssertionRequestOptions, ExecutionResult, Task> onCompletion)
{
builder.ValidateUseOfExperimentalFeature();

if (onCompletion == null)
{
throw new ArgumentNullException(nameof(onCompletion));
Expand Down Expand Up @@ -212,8 +208,6 @@ public static ConfidentialClientApplicationBuilder OnBackgroundTokenRefreshCompl
this ConfidentialClientApplicationBuilder builder,
Func<ExecutionResult, Task> onBackgroundTokenRefreshCompleted)
{
builder.ValidateUseOfExperimentalFeature();

if (onBackgroundTokenRefreshCompleted == null)
{
throw new ArgumentNullException(nameof(onBackgroundTokenRefreshCompleted));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ Task<X509Certificate2> certificateProvider(AssertionRequestOptions options)
// Act
var app = ConfidentialClientApplicationBuilder
.Create(TestConstants.ClientId)
.WithExperimentalFeatures()
.WithCertificate(certificateProvider, _certificateOptions)
.BuildConcrete();

Expand All @@ -66,7 +65,6 @@ public void WithCertificate_ThrowsOnNullCallback()
var ex = Assert.Throws<ArgumentNullException>(() =>
ConfidentialClientApplicationBuilder
.Create(TestConstants.ClientId)
.WithExperimentalFeatures()
.WithCertificate((Func<AssertionRequestOptions, Task<X509Certificate2>>) null, null)
.Build());

Expand Down Expand Up @@ -95,7 +93,6 @@ Task<X509Certificate2> secondProvider(AssertionRequestOptions options)
// Act
var app = ConfidentialClientApplicationBuilder
.Create(TestConstants.ClientId)
.WithExperimentalFeatures()
.WithCertificate(firstProvider, _certificateOptions)
.WithCertificate(secondProvider, _certificateOptions)
.BuildConcrete();
Expand All @@ -117,7 +114,6 @@ public void WithCertificate_CertificateOptions_SendX5C_True_IsStored()
// Act
var app = ConfidentialClientApplicationBuilder
.Create(TestConstants.ClientId)
.WithExperimentalFeatures()
.WithCertificate(certificateProvider, certificateOptions)
.BuildConcrete();

Expand All @@ -137,7 +133,6 @@ public void WithCertificate_CertificateOptions_SendX5C_False_IsStored()
// Act
var app = ConfidentialClientApplicationBuilder
.Create(TestConstants.ClientId)
.WithExperimentalFeatures()
.WithCertificate(certificateProvider, certificateOptions)
.BuildConcrete();

Expand All @@ -156,7 +151,6 @@ public void WithCertificate_NullCertificateOptions_DefaultsToSendX5C_False()
// Act
var app = ConfidentialClientApplicationBuilder
.Create(TestConstants.ClientId)
.WithExperimentalFeatures()
.WithCertificate(certificateProvider, null)
.BuildConcrete();

Expand All @@ -176,7 +170,6 @@ public void WithCertificate_CertificateOptions_AssociateTokensWithCertificateSer
// Act
var app = ConfidentialClientApplicationBuilder
.Create(TestConstants.ClientId)
.WithExperimentalFeatures()
.WithCertificate(certificateProvider, certificateOptions)
.BuildConcrete();

Expand All @@ -197,7 +190,6 @@ public void WithCertificate_CertificateOptions_AssociateTokensWithCertificateSer
// Act
var app = ConfidentialClientApplicationBuilder
.Create(TestConstants.ClientId)
.WithExperimentalFeatures()
.WithCertificate(certificateProvider, certificateOptions)
.BuildConcrete();

Expand All @@ -222,7 +214,6 @@ public void WithCertificate_CertificateOptions_BothPropertiesSet_AreStored()
// Act
var app = ConfidentialClientApplicationBuilder
.Create(TestConstants.ClientId)
.WithExperimentalFeatures()
.WithCertificate(certificateProvider, certificateOptions)
.BuildConcrete();

Expand All @@ -247,7 +238,6 @@ public void OnMsalServiceFailure_CallbackIsStored()
// Act
var app = ConfidentialClientApplicationBuilder
.Create(TestConstants.ClientId)
.WithExperimentalFeatures()
.WithClientSecret(TestConstants.ClientSecret)
.OnMsalServiceFailure(onMsalServiceFailureCallback)
.BuildConcrete();
Expand All @@ -263,7 +253,6 @@ public void OnMsalServiceFailure_ThrowsOnNullCallback()
var ex = Assert.Throws<ArgumentNullException>(() =>
ConfidentialClientApplicationBuilder
.Create(TestConstants.ClientId)
.WithExperimentalFeatures()
.WithClientSecret(TestConstants.ClientSecret)
.OnMsalServiceFailure(null)
.Build());
Expand All @@ -284,7 +273,6 @@ public void OnSuccess_CallbackIsStored()
// Act
var app = ConfidentialClientApplicationBuilder
.Create(TestConstants.ClientId)
.WithExperimentalFeatures()
.WithClientSecret(TestConstants.ClientSecret)
.OnCompletion(onSuccessCallback)
.BuildConcrete();
Expand All @@ -300,7 +288,6 @@ public void OnSuccess_ThrowsOnNullCallback()
var ex = Assert.Throws<ArgumentNullException>(() =>
ConfidentialClientApplicationBuilder
.Create(TestConstants.ClientId)
.WithExperimentalFeatures()
.WithClientSecret(TestConstants.ClientSecret)
.OnCompletion(null)
.Build());
Expand Down Expand Up @@ -387,7 +374,6 @@ public void AllThreeExtensibilityPoints_CanBeConfiguredTogether()
// Act
var app = ConfidentialClientApplicationBuilder
.Create(TestConstants.ClientId)
.WithExperimentalFeatures()
.WithCertificate(certificateProvider, _certificateOptions)
.OnMsalServiceFailure(onMsalServiceFailure)
.OnCompletion(onSuccess)
Expand All @@ -411,7 +397,6 @@ public void ExtensibilityPoints_CanBeConfiguredInAnyOrder()
// Act - Order: OnCompletion, OnMsalServiceFailure, Certificate
var app1 = ConfidentialClientApplicationBuilder
.Create(TestConstants.ClientId)
.WithExperimentalFeatures()
.OnCompletion(onSuccess)
.OnMsalServiceFailure(onMsalServiceFailure)
.WithCertificate(certificateProvider, _certificateOptions)
Expand All @@ -420,7 +405,6 @@ public void ExtensibilityPoints_CanBeConfiguredInAnyOrder()
// Act - Order: OnMsalServiceFailure, Certificate, OnCompletion
var app2 = ConfidentialClientApplicationBuilder
.Create(TestConstants.ClientId)
.WithExperimentalFeatures()
.OnMsalServiceFailure(onMsalServiceFailure)
.WithCertificate(certificateProvider, _certificateOptions)
.OnCompletion(onSuccess)
Expand Down Expand Up @@ -453,7 +437,6 @@ Task<X509Certificate2> certificateProvider(AssertionRequestOptions options)
// Act
var app = ConfidentialClientApplicationBuilder
.Create(TestConstants.ClientId)
.WithExperimentalFeatures()
.WithAuthority(TestConstants.AadAuthorityWithTestTenantId)
.WithCertificate(certificateProvider, _certificateOptions)
.BuildConcrete();
Expand Down
Loading
Loading