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

Fixes issue using AAD credentials with EventHubs. #6835

Merged

Conversation

mitchdenny
Copy link
Contributor

I've discovered what I think is an error in the scope value that the EventHubs client is passing to token providers when it requests a token. This incorrect value affects AAD-based credential types such as ClientSecretCredential and ManagedIdentityCredential. I didn't test the later but I'm pretty confident it'll stop any AAD based credential from working with EventHubs - so I think we probably need to ship an update to the EventHubs library.

I verified that the capitalization of Azure was the issue in the scope value by creating a man-in-the-middle token provider which substituted the scopes when fetching a token to compensate for the error. If you want a repro here you go:

public class MimCredential : ClientSecretCredential
    {
        public MimCredential(string tenantId, string clientId, string clientSecret) : base(tenantId, clientId, clientSecret)
        {
        }

        public override Task<AccessToken> GetTokenAsync(string[] scopes, CancellationToken cancellationToken = default)
        {
            scopes[0] = scopes[0].ToLower(); // HACK!!!!
            return base.GetTokenAsync(scopes, cancellationToken);
        }
    }

I also removed the (what I think) is a redundant backslash).

@mitchdenny mitchdenny requested review from jsquire and schaabs July 8, 2019 04:27
Copy link
Member

@jsquire jsquire left a comment

Choose a reason for hiding this comment

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

Thanks!

@mitchdenny mitchdenny self-assigned this Jul 8, 2019
@mitchdenny mitchdenny merged commit 70146be into Azure:master Jul 8, 2019
@mitchdenny mitchdenny deleted the fix-eventhub-scope-for-aad-auth branch July 8, 2019 17:44
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.

2 participants