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

Add managed identity client id config in DAC #13351

Merged
merged 7 commits into from
Jul 22, 2020
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.azure.identity;

import com.azure.core.credential.TokenCredential;
import com.azure.core.util.Configuration;
import com.azure.core.util.CoreUtils;
import com.azure.core.util.logging.ClientLogger;

Expand All @@ -21,9 +22,18 @@ public class DefaultAzureCredentialBuilder extends CredentialBuilderBase<Default
private String managedIdentityClientId;
private final ClientLogger logger = new ClientLogger(DefaultAzureCredentialBuilder.class);

/**
* Creates an instance of a DefaultAzureCredentialBuilder.
*/
public DefaultAzureCredentialBuilder() {
Configuration configuration = Configuration.getGlobalConfiguration().clone();
tenantId = configuration.get(Configuration.PROPERTY_AZURE_TENANT_ID);
managedIdentityClientId = configuration.get(Configuration.PROPERTY_AZURE_CLIENT_ID);
}

/**
* Sets the tenant id of the user to authenticate through the {@link DefaultAzureCredential}. The default is null
* Sets the tenant id of the user to authenticate through the {@link DefaultAzureCredential}. If unset, the value
* in the AZURE_TENANT_ID environment variable will be used. If neither is set, the default is null
* and will authenticate users to their default tenant.
*
* @param tenantId the tenant ID to set.
Expand Down Expand Up @@ -70,7 +80,9 @@ public DefaultAzureCredentialBuilder intelliJKeePassDatabasePath(String database

/**
* Specifies the client ID of user assigned or system assigned identity, when this credential is running
* in an environment with managed identities.
* in an environment with managed identities. If unset, the value in the AZURE_CLIENT_ID environment variable
* will be used. If neither is set, the default value is null and will only work with system assigned
* managed identities and not user assigned managed identities.
*
* @param clientId the client ID
* @return the DefaultAzureCredentialBuilder itself
Expand Down Expand Up @@ -115,7 +127,7 @@ private ArrayList<TokenCredential> getCredentialsChain() {
output.add(new EnvironmentCredential(identityClientOptions));
output.add(new ManagedIdentityCredential(managedIdentityClientId, identityClientOptions));
output.add(new SharedTokenCacheCredential(null, "04b07795-8ddb-461a-bbee-02f9e1bf7b46",
null, identityClientOptions));
tenantId, identityClientOptions));
output.add(new IntelliJCredential(tenantId, identityClientOptions));
output.add(new VisualStudioCodeCredential(tenantId, identityClientOptions));
output.add(new AzureCliCredential(identityClientOptions));
Expand Down