Skip to content

Commit 59bc8b1

Browse files
committed
Fix bug of cannot sign-in in Mac M1 machine
1 parent 376af74 commit 59bc8b1

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/main/java/com/microsoft/intellij/actions/AzureSignInAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ private static Single<DeviceCodeAccount> loginDeviceCodeSingle() {
292292
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
293293
indicator.setIndeterminate(true);
294294
final AzureAccount az = Azure.az(AzureAccount.class);
295-
return (DeviceCodeAccount) checkCanceled(indicator, az.loginAsync(AuthType.DEVICE_CODE, true), () -> {
295+
return (DeviceCodeAccount) checkCanceled(indicator, az.loginAsync(AuthType.DEVICE_CODE, IdentityAzureManager.shallEnablePersistence()), () -> {
296296
throw Lombok.sneakyThrow(new InterruptedException("user cancel"));
297297
});
298298
});

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/AzureModule.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public AzureModule(@Nullable Object project) {
9191
SignInOutListener signInOutListener = new SignInOutListener();
9292
AuthMethodManager.getInstance().addSignInEventListener(signInOutListener);
9393
AuthMethodManager.getInstance().addSignOutEventListener(signInOutListener);
94+
signInOutListener.run();
9495
} catch (Exception ex) {
9596
DefaultLoader.getUIHelper().logError(ex.getMessage(), ex);
9697
}

Utils/azuretools-core/src/com/microsoft/azuretools/sdkmanage/IdentityAzureManager.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package com.microsoft.azuretools.sdkmanage;
77

8+
import com.microsoft.aad.msal4jextensions.persistence.mac.ISecurityLibrary;
89
import com.microsoft.azure.credentials.AzureTokenCredentials;
910
import com.microsoft.azure.management.resources.Tenant;
1011
import com.microsoft.azure.toolkit.ide.common.store.AzureStoreManager;
@@ -26,6 +27,7 @@
2627
import com.microsoft.azuretools.authmanage.models.SubscriptionDetail;
2728
import org.apache.commons.collections4.CollectionUtils;
2829
import org.apache.commons.lang3.StringUtils;
30+
import org.apache.commons.lang3.SystemUtils;
2931
import reactor.core.publisher.Mono;
3032

3133
import java.io.IOException;
@@ -124,7 +126,18 @@ public Mono<AuthMethodDetails> signInAzureCli() {
124126

125127
public Mono<AuthMethodDetails> signInOAuth() {
126128
AzureAccount az = com.microsoft.azure.toolkit.lib.Azure.az(AzureAccount.class);
127-
return az.loginAsync(AuthType.OAUTH2, true).flatMap(Account::continueLogin).map(account -> fromAccountEntity(account.getEntity()));
129+
return az.loginAsync(AuthType.OAUTH2, shallEnablePersistence()).flatMap(Account::continueLogin).map(account -> fromAccountEntity(account.getEntity()));
130+
}
131+
132+
public static boolean shallEnablePersistence() {
133+
if (SystemUtils.IS_OS_MAC) {
134+
try {
135+
ISecurityLibrary.library.CFRelease(null);
136+
} catch (Throwable ex) {
137+
return false;
138+
}
139+
}
140+
return true;
128141
}
129142

130143
public Mono<AuthMethodDetails> restoreSignIn(AuthMethodDetails authMethodDetails) {

0 commit comments

Comments
 (0)