-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
ManagedIdentityTokenProvider change #6637
ManagedIdentityTokenProvider change #6637
Conversation
bainian12345
commented
Jun 19, 2019
- Allow connection string to accept both "Managed Identity" and "ManagedIdentity"
- Remove default authority for ManagedIdentityTokenProvider
Pull latest master
pull latest master
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I left a couple of comments for some minor things.
@@ -25,7 +20,7 @@ public class AzureActiveDirectoryTokenProvider : TokenProvider | |||
public AzureActiveDirectoryTokenProvider(AuthenticationCallback authenticationCallback, string authority, object state) | |||
{ | |||
this.AuthCallback = authenticationCallback ?? throw Fx.Exception.ArgumentNull(nameof(authenticationCallback)); | |||
this.authority = authority ?? CommonAuthority; | |||
this.authority = authority; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider validating the authority
as not null or empty? Seems better to catch that up front then failing when trying to acquire a token later.
@@ -79,7 +79,7 @@ public static TokenProvider CreateSharedAccessSignatureTokenProvider(string keyN | |||
/// <returns>The <see cref="Microsoft.ServiceBus.TokenProvider" /> for returning Json web token.</returns> | |||
public static TokenProvider CreateAzureActiveDirectoryTokenProvider( | |||
AzureActiveDirectoryTokenProvider.AuthenticationCallback authCallback, | |||
string authority = AzureActiveDirectoryTokenProvider.CommonAuthority, | |||
string authority, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider validating the authority
as not null or empty? Seems better to catch that up front then failing when trying to acquire a token later.
sdk/servicebus/Microsoft.Azure.ServiceBus/src/ServiceBusConnectionStringBuilder.cs
Show resolved
Hide resolved
sdk/servicebus/Microsoft.Azure.ServiceBus/src/ServiceBusConnectionStringBuilder.cs
Show resolved
Hide resolved
sdk/servicebus/Microsoft.Azure.ServiceBus/tests/ServiceBusConnectionStringBuilderTests.cs
Show resolved
Hide resolved
{ | ||
public const string ManagedIdentity = "Managed Identity"; | ||
None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None [](start = 12, length = 4)
This is interesting. For customers who are using SASTokens or SASKeys, this authenticationType would be None. Which is quite confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The initial implementation is also string-based, but it is in the process of being given an overhaul, where the new API surface will simply take a token credential that the Azure.Identity
library is responsible for producing. As a general rule, authentication should be an external concern; authorization against the resource is an internal one.
{ | ||
connectionStringBuilder.Append(AuthenticationConfigName).Append(KeyValueSeparator).Append(this.Authentication).Append(KeyValuePairDelimiter); | ||
connectionStringBuilder.Append(AuthenticationConfigName).Append(KeyValueSeparator).Append("Managed Identity").Append(KeyValuePairDelimiter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Managed Identity" [](start = 106, length = 18)
Can we convert this to a constant on top of this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.