Skip to content

Commit 865d14f

Browse files
authored
Merge pull request #5266 from microsoft/feature-sp-new
Merage feature sp login
2 parents bc34d52 + 355d1a9 commit 865d14f

File tree

13 files changed

+644
-304
lines changed

13 files changed

+644
-304
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*/
5+
6+
package com.microsoft.azure.toolkit.intellij.common;
7+
8+
import com.intellij.openapi.util.SystemInfo;
9+
import com.intellij.ui.components.JBLabel;
10+
import com.intellij.ui.scale.JBUIScale;
11+
import com.intellij.util.ui.UIUtil;
12+
import org.jetbrains.annotations.NotNull;
13+
14+
import javax.swing.plaf.FontUIResource;
15+
import javax.swing.plaf.LabelUI;
16+
import java.awt.*;
17+
18+
public class AzureCommentLabel extends JBLabel {
19+
public AzureCommentLabel(@NotNull String text) {
20+
super(text);
21+
setForeground(UIUtil.getContextHelpForeground());
22+
}
23+
24+
@Override
25+
public void setUI(LabelUI ui) {
26+
super.setUI(ui);
27+
28+
if (SystemInfo.isMac) {
29+
Font font = getFont();
30+
float size = font.getSize2D();
31+
font = new FontUIResource(font.deriveFont(size - JBUIScale.scale(2))); // Allow to reset the font by UI
32+
setFont(font);
33+
}
34+
}
35+
}

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import com.intellij.openapi.project.Project;
1212
import com.intellij.openapi.ui.DialogWrapper;
1313
import com.intellij.openapi.wm.WindowManager;
14+
import com.microsoft.azure.toolkit.lib.Azure;
15+
import com.microsoft.azure.toolkit.lib.auth.AzureAccount;
1416
import com.microsoft.azure.toolkit.lib.auth.exception.AzureToolkitAuthenticationException;
1517
import com.microsoft.azure.toolkit.lib.auth.model.AuthType;
1618
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
@@ -91,7 +93,7 @@ private static String getSignOutWarningMessage(@NotNull AuthMethodManager authMe
9193
final String warningMessage;
9294
switch (authType) {
9395
case SERVICE_PRINCIPAL:
94-
warningMessage = String.format("Signed in using file \"%s\"", authMethodDetails.getCredFilePath());
96+
warningMessage = String.format("Signed in using service principal \"%s\"", authMethodDetails.getClientId());
9597
break;
9698
case OAUTH2:
9799
case DEVICE_CODE:
@@ -123,7 +125,16 @@ public static void onAzureSignIn(Project project) {
123125
});
124126
}
125127
} else {
126-
doSignIn(authMethodManager, project).subscribe();
128+
doSignIn(authMethodManager, project).subscribe(r -> {
129+
if (r) {
130+
AzureAccount az = Azure.az(AzureAccount.class);
131+
authMethodManager.getAzureManager().getSelectedSubscriptions().stream().limit(5).forEach(s -> {
132+
// pre-load regions;
133+
az.listRegions(s.getId());
134+
});
135+
}
136+
137+
});
127138
}
128139
}
129140

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/helpers/MvpUIHelperImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
package com.microsoft.intellij.helpers;
77

8+
import com.microsoft.azuretools.azurecommons.helpers.NotNull;
89
import com.microsoft.azuretools.core.mvp.ui.base.MvpUIHelper;
10+
import com.microsoft.intellij.secure.IdeaSecureStore;
911
import com.microsoft.tooling.msservices.components.DefaultLoader;
1012

1113
import javax.swing.*;
@@ -21,4 +23,10 @@ public void showError(String msg) {
2123
public void showException(String msg, Exception e) {
2224
DefaultLoader.getUIHelper().showError(e.getMessage(), msg);
2325
}
26+
27+
@Deprecated
28+
@Override
29+
public String loadPasswordFromSecureStore(@NotNull String key) {
30+
return IdeaSecureStore.getInstance().loadPassword(key);
31+
}
2432
}
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.microsoft.intellij.ui.ServicePrincipalLoginDialog">
3+
<grid id="8fe86" binding="rootPanel" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
4+
<margin top="0" left="0" bottom="0" right="0"/>
5+
<constraints>
6+
<xy x="0" y="0" width="604" height="346"/>
7+
</constraints>
8+
<properties>
9+
<minimumSize width="430" height="246"/>
10+
</properties>
11+
<border type="none"/>
12+
<children>
13+
<component id="cf56f" class="javax.swing.JLabel">
14+
<constraints>
15+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false">
16+
<minimum-size width="80" height="24"/>
17+
<preferred-size width="80" height="24"/>
18+
<maximum-size width="80" height="24"/>
19+
</grid>
20+
</constraints>
21+
<properties>
22+
<labelFor value="ee53a"/>
23+
<text value="Tenant Id:"/>
24+
</properties>
25+
</component>
26+
<component id="5412b" class="javax.swing.JLabel">
27+
<constraints>
28+
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false">
29+
<minimum-size width="80" height="24"/>
30+
<preferred-size width="80" height="24"/>
31+
<maximum-size width="80" height="24"/>
32+
</grid>
33+
</constraints>
34+
<properties>
35+
<labelFor value="6d153"/>
36+
<text value="Client Id:"/>
37+
</properties>
38+
</component>
39+
<component id="7ce5a" class="com.intellij.ui.EditorTextField" binding="jsonDataEditor" custom-create="true">
40+
<constraints>
41+
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false">
42+
<preferred-size width="15" height="25"/>
43+
</grid>
44+
</constraints>
45+
<properties/>
46+
</component>
47+
<component id="ee53a" class="javax.swing.JTextField" binding="tenantIdTextField">
48+
<constraints>
49+
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="9" fill="1" indent="0" use-parent-layout="false">
50+
<preferred-size width="150" height="24"/>
51+
</grid>
52+
</constraints>
53+
<properties/>
54+
</component>
55+
<component id="6d153" class="javax.swing.JTextField" binding="clientIdTextField">
56+
<constraints>
57+
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
58+
<preferred-size width="150" height="-1"/>
59+
</grid>
60+
</constraints>
61+
<properties/>
62+
</component>
63+
<grid id="39488" layout-manager="FormLayout">
64+
<rowspec value="center:d:grow"/>
65+
<rowspec value="top:4dlu:noGrow"/>
66+
<rowspec value="center:d:grow"/>
67+
<colspec value="fill:max(d;4px):noGrow"/>
68+
<colspec value="left:4dlu:noGrow"/>
69+
<colspec value="fill:d:grow"/>
70+
<constraints>
71+
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
72+
</constraints>
73+
<properties/>
74+
<border type="none"/>
75+
<children>
76+
<component id="fce4f" class="javax.swing.JRadioButton" binding="passwordRadioButton" default-binding="true">
77+
<constraints>
78+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
79+
<minimum-size width="80" height="24"/>
80+
<preferred-size width="80" height="24"/>
81+
<maximum-size width="80" height="24"/>
82+
</grid>
83+
<forms/>
84+
</constraints>
85+
<properties>
86+
<selected value="true"/>
87+
<text value="Password:"/>
88+
</properties>
89+
</component>
90+
<component id="93cc5" class="javax.swing.JPasswordField" binding="keyPasswordField">
91+
<constraints>
92+
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
93+
<preferred-size width="150" height="-1"/>
94+
</grid>
95+
<forms defaultalign-horz="false"/>
96+
</constraints>
97+
<properties/>
98+
</component>
99+
<component id="18bfd" class="javax.swing.JRadioButton" binding="certificateRadioButton">
100+
<constraints>
101+
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
102+
<minimum-size width="80" height="24"/>
103+
<preferred-size width="80" height="24"/>
104+
<maximum-size width="80" height="24"/>
105+
</grid>
106+
<forms/>
107+
</constraints>
108+
<properties>
109+
<text value="Certificate:"/>
110+
</properties>
111+
</component>
112+
<component id="1d59a" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="certFileTextField">
113+
<constraints>
114+
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
115+
<forms/>
116+
</constraints>
117+
<properties>
118+
<editable value="false"/>
119+
<text value=""/>
120+
</properties>
121+
</component>
122+
</children>
123+
</grid>
124+
<component id="dd0cb" class="javax.swing.JLabel">
125+
<constraints>
126+
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false">
127+
<minimum-size width="80" height="24"/>
128+
<preferred-size width="80" height="24"/>
129+
<maximum-size width="80" height="24"/>
130+
</grid>
131+
</constraints>
132+
<properties>
133+
<text value="Secret:"/>
134+
</properties>
135+
</component>
136+
<component id="42843" class="javax.swing.JLabel">
137+
<constraints>
138+
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false">
139+
<minimum-size width="80" height="24"/>
140+
<preferred-size width="80" height="24"/>
141+
<maximum-size width="80" height="24"/>
142+
</grid>
143+
</constraints>
144+
<properties>
145+
<text value="JSON:"/>
146+
</properties>
147+
</component>
148+
<component id="9015b" class="com.microsoft.azure.toolkit.intellij.common.AzureCommentLabel" binding="comment" custom-create="true">
149+
<constraints>
150+
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
151+
</constraints>
152+
<properties/>
153+
</component>
154+
</children>
155+
</grid>
156+
<buttonGroups>
157+
<group name="buttonGroup1">
158+
<member id="fce4f"/>
159+
<member id="18bfd"/>
160+
</group>
161+
</buttonGroups>
162+
</form>

0 commit comments

Comments
 (0)