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

[POC] AAD: Configuring ServerTelemetryChannel and QuickPulseServiceClient #2220

Closed
wants to merge 116 commits into from

Conversation

TimothyMothra
Copy link
Member

@TimothyMothra TimothyMothra commented Apr 9, 2021

Consuming CredentialEnvelope within TelemetryChannels and QuickPulseServiceClient

For more information see the parent item: #2190.

Introduction

This PR demonstrates an approach to handling the configuration of the CredentialEnvelope.

TODO: Need to write unit tests to validate possible configuration scenarios.

TelemetryConfiguration

TelemetryConfiguration has a method SetAzureTokenCredential for a user to provide the TokenCredential.
This method could be called either before or after the user has set the TelemetryChannel.

To deal with this, both setting a credential and setting a TelemetryChannel will invoke TelemetryConfiguration.SetTelemetryChannelCredentialEnvelope.

ISupportCredentialEnvelope

To simplify passing the CredentialEnvelope to the TelemetryChannels, I've introduced a new interface ISupportCredentialEnvelope.
This ensures that the TelemetryConfiguration can set either InMemoryChannel or ServerTelemetryChannel.

TelemetryChannels

Each TelemetryChannel must provide the CredentialEnvelope on their respective internal classes.
TelemetryItems ultimately end up stored in a Transmission object. This object can be serialized for file storage. I've confirmed that the Credential object will not be serialized.

Tokens themselves will expire and therefore are not set on the Transmission object until just before invoking Transmission.SendAsync. If a Transmission needs to be retried, it will receive a new token.

InMemoryChannel

InMemoryChannel.CredentialEnvelope sets InMemoryTransmitter.CredentialEnvelope which is used to set Transmission.CredentialEnvelope just before calling Transmission.SendAsync.

ServerTelemetryChannel

ServerTelemetryChannel.CredentialEnvelope sets Transmitter.CredentialEnvelope and then sets TransmissionSender.CredentialEnvelope which is used to set Transmission.CredentialEnvelope just before calling Transmission.SendAsync.


if (aadToken == null)
{
// TODO: DO NOT SEND. RETURN FAILURE AND LET CHANNEL DECIDE WHEN TO RETRY.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be considered a client side failure, and data would not be retried by default.
Its probably a complex part to decide if we want to store items for later retry, if the AAD is down..

@@ -381,6 +386,12 @@ private void AddHeaders(HttpWebRequest request, bool includeIdentityHeaders, str
request.Headers.Add(QuickPulseConstants.XMsQpsInvariantVersionHeaderName,
MonitoringDataPoint.CurrentInvariantVersion.ToString(CultureInfo.InvariantCulture));
}

// The AAD token is an optional feature. Only include if it is provided.
if (!string.IsNullOrEmpty(aadToken))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this intentionally optional for QP? elsewhere, in the regular channel, its like mandatory, if user has set tc.settokencred.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh good catch. i need to rethink this

@TimothyMothra TimothyMothra mentioned this pull request May 28, 2021
4 tasks
@TimothyMothra TimothyMothra changed the title AAD: Configuring TelemetryChannels and QuickPulse AAD: Configuring ServerTelemetryChannel and QuickPulseServiceClient May 29, 2021
@TimothyMothra TimothyMothra changed the title AAD: Configuring ServerTelemetryChannel and QuickPulseServiceClient [POC] AAD: Configuring ServerTelemetryChannel and QuickPulseServiceClient May 29, 2021
This was referenced May 29, 2021
@@ -96,6 +95,20 @@ public TimeSpan SendingInterval
}
}

/// <summary>
/// Gets or sets the <see cref="CredentialEnvelope"/> which is used for AAD.
/// FOR INTERNAL USE. Customers should use <see cref="TelemetryConfiguration.SetAzureTokenCredential"/> instead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't really need this comment anymore since ISupportCredentialEnvelope is, itself, internal.

@@ -107,6 +108,15 @@ public virtual int ThrottleWindow
}
}

/// <summary>
/// Gets or sets the <see cref="CredentialEnvelope"/> which is used for AAD.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of "AAD", suggest "authorization" or "auth-token acquisition".

@TimothyMothra TimothyMothra deleted the tilee/feature_aad_w_config branch June 3, 2021 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants