Skip to content

AppAuthentication 1.1.0-preview: TenantId is mandatory in connection string with RunAs=App #4169

@johanclasson

Description

@johanclasson

The ClientCertificateAzureServiceTokenProvider seams to only use the tenant id in its method GetTokenAsync if the authority parameter is null or white space. But some clients, for example the KeyVaultClient of Microsoft.Azure.KeyVault, provides a authority parameter. This makes the TenantId-part of the connection string possibly redundant.

For example, the following code works just fine:

var azureServiceTokenProvider = new AzureServiceTokenProvider(
    $"RunAs=App;AppId={appId};TenantId=NotNeeded;CertificateThumbprint={thumbprint};CertificateStoreLocation=CurrentUser");
var keyVaultClient = new KeyVaultClient(
    new KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback));
var secret = await keyVaultClient.GetSecretAsync(secretIdentifier).ConfigureAwait(false);

I propose making the TenantId optional and instead throw in ClientCertificateAzureServiceTokenProvider.GetTokenAsync if authority is null or white space and _tenantId is not set.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions