Skip to content

Commit 9ecce67

Browse files
author
Timothy Mothra
authored
AAD: refactor (#2288)
* AAD: refactor * change property to internal
1 parent 353d122 commit 9ecce67

File tree

8 files changed

+33
-24
lines changed

8 files changed

+33
-24
lines changed

.publicApi/Microsoft.ApplicationInsights.dll/net452/PublicAPI.Unshipped.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
abstract Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope.GetToken(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> string
2+
abstract Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope.GetTokenAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<string>
3+
Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope
4+
Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope.CredentialEnvelope() -> void
5+
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.CredentialEnvelope.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope
16
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.SetAzureTokenCredential(object tokenCredential) -> void
2-
37
Microsoft.ApplicationInsights.Channel.IAsyncFlushable
48
Microsoft.ApplicationInsights.Channel.IAsyncFlushable.FlushAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<bool>
59
Microsoft.ApplicationInsights.Channel.InMemoryChannel.FlushAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<bool>

.publicApi/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
abstract Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope.GetToken(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> string
2+
abstract Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope.GetTokenAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<string>
3+
Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope
4+
Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope.CredentialEnvelope() -> void
5+
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.CredentialEnvelope.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope
16
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.SetAzureTokenCredential(object tokenCredential) -> void
2-
37
Microsoft.ApplicationInsights.Channel.IAsyncFlushable
48
Microsoft.ApplicationInsights.Channel.IAsyncFlushable.FlushAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<bool>
59
Microsoft.ApplicationInsights.Channel.InMemoryChannel.FlushAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<bool>

.publicApi/Microsoft.ApplicationInsights.dll/netstandard2.0/PublicAPI.Unshipped.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
abstract Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope.GetToken(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> string
2+
abstract Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope.GetTokenAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<string>
3+
Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope
4+
Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope.CredentialEnvelope() -> void
5+
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.CredentialEnvelope.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope
16
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.SetAzureTokenCredential(object tokenCredential) -> void
2-
37
Microsoft.ApplicationInsights.Channel.IAsyncFlushable
48
Microsoft.ApplicationInsights.Channel.IAsyncFlushable.FlushAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<bool>
59
Microsoft.ApplicationInsights.Channel.InMemoryChannel.FlushAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<bool>

BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Extensibility/Implementation/Authentication/ReflectionCredentialEnvelopeTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public async Task VerifyGetTokenAsync_UsingDynamicTypes()
118118
[TestMethod]
119119
public void VerifyGetToken_ReturnsValidToken()
120120
{
121-
var requestContext = new TokenRequestContext(scopes: CredentialConstants.GetScopes());
121+
var requestContext = new TokenRequestContext(scopes: AuthConstants.GetScopes());
122122
var mockCredential = new MockCredential();
123123
var tokenUsingTypes = mockCredential.GetToken(requestContext, CancellationToken.None);
124124

@@ -134,7 +134,7 @@ public void VerifyGetToken_ReturnsValidToken()
134134
[TestMethod]
135135
public async Task VerifyGetTokenAsync_ReturnsValidToken()
136136
{
137-
var requestContext = new TokenRequestContext(scopes: CredentialConstants.GetScopes());
137+
var requestContext = new TokenRequestContext(scopes: AuthConstants.GetScopes());
138138
var mockCredential = new MockCredential();
139139
var tokenUsingTypes = await mockCredential.GetTokenAsync(requestContext, CancellationToken.None);
140140

BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Authentication/CredentialConstants.cs renamed to BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Authentication/AuthConstants.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
namespace Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication
22
{
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using System.Text;
7-
using System.Threading.Tasks;
8-
9-
internal static class CredentialConstants
3+
internal static class AuthConstants
104
{
115
/// <summary>
126
/// Source:
137
/// (https://docs.microsoft.com/azure/active-directory/develop/msal-acquire-cache-tokens#scopes-when-acquiring-tokens).
148
/// (https://docs.microsoft.com/azure/active-directory/develop/v2-permissions-and-consent#the-default-scope).
159
/// </summary>
16-
public const string AzureMonitorScope = "https://monitor.azure.com//.default"; // TODO: THIS SCOPE IS UNVERIFIED. WAITING FOR SERVICES TEAM TO PROVIDE AN INT ENVIRONMENT FOR E2E TESTING.
10+
private const string AzureMonitorScope = "https://monitor.azure.com//.default"; // TODO: THIS SCOPE IS UNVERIFIED. WAITING FOR SERVICES TEAM TO PROVIDE AN INT ENVIRONMENT FOR E2E TESTING.
1711

1812
/// <summary>
1913
/// Get scopes for Azure Monitor as an array.

BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Authentication/ICredentialEnvelope.cs renamed to BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Authentication/CredentialEnvelope.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,28 @@
33
using System.Threading;
44
using System.Threading.Tasks;
55

6-
internal interface ICredentialEnvelope
6+
/// <summary>
7+
/// This interface defines a class that can interact with Azure.Core.TokenCredential.
8+
/// </summary>
9+
public abstract class CredentialEnvelope
710
{
811
/// <summary>
912
/// Gets the TokenCredential instance held by this class.
1013
/// </summary>
11-
object Credential { get; }
14+
internal abstract object Credential { get; }
1215

1316
/// <summary>
1417
/// Gets an Azure.Core.AccessToken.
1518
/// </summary>
1619
/// <param name="cancellationToken">The System.Threading.CancellationToken to use.</param>
1720
/// <returns>A valid Azure.Core.AccessToken.</returns>
18-
string GetToken(CancellationToken cancellationToken = default);
21+
public abstract string GetToken(CancellationToken cancellationToken = default);
1922

2023
/// <summary>
2124
/// Gets an Azure.Core.AccessToken.
2225
/// </summary>
2326
/// <param name="cancellationToken">The System.Threading.CancellationToken to use.</param>
2427
/// <returns>A valid Azure.Core.AccessToken.</returns>
25-
Task<string> GetTokenAsync(CancellationToken cancellationToken = default);
28+
public abstract Task<string> GetTokenAsync(CancellationToken cancellationToken = default);
2629
}
27-
}
30+
}

BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Authentication/ReflectionCredentialEnvelope.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/// Our SDK currently targets net452, net46, and netstandard2.0.
1616
/// Azure.Core.TokenCredential is only available for netstandard2.0.
1717
/// </remarks>
18-
internal class ReflectionCredentialEnvelope : ICredentialEnvelope
18+
internal class ReflectionCredentialEnvelope : CredentialEnvelope
1919
{
2020
private readonly object tokenCredential;
2121
private readonly object tokenRequestContext;
@@ -30,7 +30,7 @@ public ReflectionCredentialEnvelope(object tokenCredential)
3030

3131
if (tokenCredential.GetType().IsSubclassOf(Type.GetType("Azure.Core.TokenCredential, Azure.Core")))
3232
{
33-
this.tokenRequestContext = AzureCore.MakeTokenRequestContext(scopes: CredentialConstants.GetScopes());
33+
this.tokenRequestContext = AzureCore.MakeTokenRequestContext(scopes: AuthConstants.GetScopes());
3434
}
3535
else
3636
{
@@ -41,14 +41,14 @@ public ReflectionCredentialEnvelope(object tokenCredential)
4141
/// <summary>
4242
/// Gets the TokenCredential instance held by this class.
4343
/// </summary>
44-
public object Credential => this.tokenCredential;
44+
internal override object Credential => this.tokenCredential;
4545

4646
/// <summary>
4747
/// Gets an Azure.Core.AccessToken.
4848
/// </summary>
4949
/// <param name="cancellationToken">The System.Threading.CancellationToken to use.</param>
5050
/// <returns>A valid Azure.Core.AccessToken.</returns>
51-
public string GetToken(CancellationToken cancellationToken = default)
51+
public override string GetToken(CancellationToken cancellationToken = default)
5252
{
5353
SdkInternalOperationsMonitor.Enter();
5454
try
@@ -71,7 +71,7 @@ public string GetToken(CancellationToken cancellationToken = default)
7171
/// </summary>
7272
/// <param name="cancellationToken">The System.Threading.CancellationToken to use.</param>
7373
/// <returns>A valid Azure.Core.AccessToken.</returns>
74-
public async Task<string> GetTokenAsync(CancellationToken cancellationToken = default)
74+
public override async Task<string> GetTokenAsync(CancellationToken cancellationToken = default)
7575
{
7676
SdkInternalOperationsMonitor.Enter();
7777
try

BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ public string ConnectionString
338338
/// <summary>
339339
/// Gets an envelope for Azure.Core.TokenCredential which provides an AAD Authenticated token.
340340
/// </summary>
341-
internal ICredentialEnvelope CredentialEnvelope { get; private set; }
341+
public CredentialEnvelope CredentialEnvelope { get; private set; }
342342

343343
/// <summary>
344344
/// Gets or sets the chain of processors.

0 commit comments

Comments
 (0)