File tree Expand file tree Collapse file tree 6 files changed +54
-2
lines changed
sdk/identity/azure-identity
src/main/java/com/azure/identity Expand file tree Collapse file tree 6 files changed +54
-2
lines changed Original file line number Diff line number Diff line change 55### Features Added
66- Added CAE support to service principal authentication.
77- Pass more detailed refresh policy for managed identity tokens to MSAL.
8+ - Add configurable timeout for developer credentials (Azure CLI, Azure Developer CLI)
89
910### Bugs Fixed
1011- Fixed detection logic for az/azd.
Original file line number Diff line number Diff line change 77import com .azure .identity .implementation .util .IdentityUtil ;
88import com .azure .identity .implementation .util .ValidationUtil ;
99
10+ import java .time .Duration ;
1011import java .util .Arrays ;
1112import java .util .List ;
1213
@@ -55,6 +56,16 @@ public AzureCliCredentialBuilder tenantId(String tenantId) {
5556 return this ;
5657 }
5758
59+ /**
60+ * Specifies a {@link Duration} timeout for calling the Azure CLI.
61+ * @param duration The {@link Duration} to wait.
62+ * @return An updated instance of this builder with the timeout specified.
63+ */
64+ public AzureCliCredentialBuilder azureCliCredentialTimeout (Duration duration ) {
65+ this .identityClientOptions .setDeveloperCredentialTimeout (duration );
66+ return this ;
67+ }
68+
5869 /**
5970 * Creates a new {@link AzureCliCredential} with the current configurations.
6071 *
Original file line number Diff line number Diff line change 77import com .azure .identity .implementation .util .IdentityUtil ;
88import com .azure .identity .implementation .util .ValidationUtil ;
99
10+ import java .time .Duration ;
1011import java .util .Arrays ;
1112import java .util .List ;
1213
@@ -32,6 +33,16 @@ public AzureDeveloperCliCredentialBuilder tenantId(String tenantId) {
3233 return this ;
3334 }
3435
36+ /**
37+ * Specifies a {@link Duration} timeout for calling the Azure Developer CLI.
38+ * @param duration The {@link Duration} to wait.
39+ * @return An updated instance of this builder with the timeout specified.
40+ */
41+ public AzureDeveloperCliCredentialBuilder azureDeveloperCliCredentialTimeout (Duration duration ) {
42+ this .identityClientOptions .setDeveloperCredentialTimeout (duration );
43+ return this ;
44+ }
45+
3546 /**
3647 * Creates a new {@link AzureDeveloperCliCredential} with the current configurations.
3748 *
Original file line number Diff line number Diff line change 1111import com .azure .identity .implementation .util .IdentityConstants ;
1212import com .azure .identity .implementation .util .IdentityUtil ;
1313
14+ import java .time .Duration ;
1415import java .util .ArrayList ;
1516import java .util .Arrays ;
1617import java .util .List ;
@@ -218,6 +219,16 @@ public DefaultAzureCredentialBuilder additionallyAllowedTenants(List<String> add
218219 return this ;
219220 }
220221
222+ /**
223+ * Specifies a {@link Duration} timeout for developer credentials (such as Azure CLI or IntelliJ).
224+ * @param duration The {@link Duration} to wait.
225+ * @return An updated instance of this builder with the timeout specified.
226+ */
227+ public DefaultAzureCredentialBuilder developerCredentialTimeout (Duration duration ) {
228+ this .identityClientOptions .setDeveloperCredentialTimeout (duration );
229+ return this ;
230+ }
231+
221232 /**
222233 * Disable instance discovery. Instance discovery is acquiring metadata about an authority from https://login.microsoft.com
223234 * to validate that authority. This may need to be disabled in private cloud or ADFS scenarios.
Original file line number Diff line number Diff line change @@ -478,7 +478,7 @@ AccessToken getTokenFromAzureCLIAuthentication(StringBuilder azCommand) {
478478 }
479479 String processOutput = output .toString ();
480480
481- process .waitFor (10 , TimeUnit .SECONDS );
481+ process .waitFor (this . options . getDeveloperCredentialTimeout (). getSeconds () , TimeUnit .SECONDS );
482482
483483 if (process .exitValue () != 0 ) {
484484 if (processOutput .length () > 0 ) {
@@ -571,7 +571,7 @@ AccessToken getTokenFromAzureDeveloperCLIAuthentication(StringBuilder azdCommand
571571 String processOutput = output .toString ();
572572
573573 // wait until the process completes or the timeout (10 sec) is reached.
574- process .waitFor (10 , TimeUnit .SECONDS );
574+ process .waitFor (this . options . getDeveloperCredentialTimeout (). getSeconds () , TimeUnit .SECONDS );
575575
576576 if (process .exitValue () != 0 ) {
577577 if (processOutput .length () > 0 ) {
Original file line number Diff line number Diff line change @@ -70,6 +70,8 @@ public final class IdentityClientOptions implements Cloneable {
7070 private List <HttpPipelinePolicy > perRetryPolicies ;
7171 private boolean instanceDiscovery ;
7272
73+ private Duration developerCredentialTimeout = Duration .ofSeconds (10 );
74+
7375 /**
7476 * Creates an instance of IdentityClientOptions with default settings.
7577 */
@@ -689,6 +691,22 @@ private void loadFromConfiguration(Configuration configuration) {
689691 .get (AZURE_IDENTITY_DISABLE_MULTI_TENANT_AUTH , false );
690692 }
691693
694+ /**
695+ * Gets the timeout to apply to developer credential operations.
696+ * @return The timeout value for developer credential operations.
697+ */
698+ public Duration getDeveloperCredentialTimeout () {
699+ return developerCredentialTimeout ;
700+ }
701+
702+ /**
703+ * Sets the timeout for developer credential operations.
704+ * @param developerCredentialTimeout The timeout value for developer credential operations.
705+ */
706+ public void setDeveloperCredentialTimeout (Duration developerCredentialTimeout ) {
707+ this .developerCredentialTimeout = developerCredentialTimeout ;
708+ }
709+
692710 public IdentityClientOptions clone () {
693711 IdentityClientOptions clone = new IdentityClientOptions ()
694712 .setAdditionallyAllowedTenants (this .additionallyAllowedTenants )
You can’t perform that action at this time.
0 commit comments