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

Introducing Verification Code for SSO Login #450

Merged
merged 7 commits into from
Dec 11, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
🛂 v2 for the new SSO login
noyshabtay committed Dec 7, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit d3f0ac206ba90d503e18df9c6addc46eebfaa350
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@
</properties>
<border type="none"/>
<children>
<grid id="b0c38" binding="connectionDetails" layout-manager="GridLayoutManager" row-count="16" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="b0c38" binding="connectionDetails" layout-manager="GridLayoutManager" row-count="17" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<tabbedpane title="Connection Details"/>
@@ -126,7 +126,7 @@
</grid>
<component id="27f28" class="javax.swing.JButton" binding="loginButton">
<constraints>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<horizontalTextPosition value="10"/>
@@ -135,94 +135,94 @@
</component>
<component id="a71b8" class="javax.swing.JLabel" binding="authenticationMethodTitle">
<constraints>
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Authentication method"/>
</properties>
</component>
<component id="6f374" class="javax.swing.JRadioButton" binding="usernamePasswordRadioButton" default-binding="true">
<constraints>
<grid row="8" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Username and password"/>
</properties>
</component>
<component id="aff26" class="javax.swing.JRadioButton" binding="accessTokenRadioButton" default-binding="true">
<constraints>
<grid row="8" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="9" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Access token"/>
</properties>
</component>
<component id="a8f26" class="javax.swing.JLabel" binding="usernameTitle">
<constraints>
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="10" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Username"/>
</properties>
</component>
<component id="d208" class="com.intellij.ui.components.JBTextField" binding="username">
<constraints>
<grid row="9" column="1" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
<grid row="10" column="1" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="59d39" class="javax.swing.JLabel" binding="passwordTitle">
<constraints>
<grid row="10" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="11" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Password"/>
</properties>
</component>
<component id="38b32" class="com.intellij.ui.components.JBPasswordField" binding="password">
<constraints>
<grid row="10" column="1" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
<grid row="11" column="1" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="92e18" class="javax.swing.JLabel" binding="accessTokenTitle">
<constraints>
<grid row="11" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="12" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Access token"/>
</properties>
</component>
<component id="89090" class="com.intellij.ui.components.JBPasswordField" binding="accessToken" default-binding="true">
<constraints>
<grid row="11" column="1" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
<grid row="12" column="1" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<vspacer id="d7093">
<constraints>
<grid row="12" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="13" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="b81b8" class="com.intellij.ui.TitledSeparator">
<constraints>
<grid row="13" column="0" row-span="1" col-span="4" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="14" column="0" row-span="1" col-span="4" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Connection Testing"/>
</properties>
</component>
<component id="62866" class="javax.swing.JButton" binding="testConnectionButton" default-binding="true">
<constraints>
<grid row="14" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="15" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Test connection"/>
</properties>
</component>
<component id="344ac" class="com.intellij.ui.components.JBLabel" binding="connectionResults">
<constraints>
<grid row="14" column="1" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="15" column="1" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="true"/>
@@ -246,16 +246,24 @@
</component>
<component id="5d973" class="com.intellij.ui.HyperlinkLabel" binding="infoPanel">
<constraints>
<grid row="15" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
<grid row="16" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="fd2cc" class="javax.swing.JLabel" binding="ssoLoginInstructionsLabel">
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="8" column="0" row-span="1" col-span="4" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="SSO label"/>
</properties>
</component>
<component id="a0ab" class="javax.swing.JLabel" binding="SSOCode">
<constraints>
<grid row="7" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Label"/>
<text value="SSO code"/>
</properties>
</component>
</children>
Original file line number Diff line number Diff line change
@@ -130,6 +130,7 @@ public class JFrogGlobalConfiguration implements Configurable, Configurable.NoSc
private JBLabel pluginResourcesDescJBLabel;
private JBLabel releasesRepoLinkJBLabel;
private JLabel ssoLoginInstructionsLabel;
private JLabel SSOCode;

private int selectedTabIndex;

@@ -472,6 +473,8 @@ private void initAdvancedExpandButton() {
* Init the "Login" button that do the SSO login.
*/
private void initLoginViaBrowserButton() {
SSOCode.setText("");
ssoLoginInstructionsLabel.setText("");
loginButton.setIcon(AllIcons.Ide.External_link_arrow);
loginButton.addActionListener(e -> ApplicationManager.getApplication().executeOnPooledThread(() -> {
if (isBlank(platformUrl.getText())) {
@@ -488,7 +491,8 @@ private void initLoginViaBrowserButton() {
private void doSsoLogin() {
String uuid = UUID.randomUUID().toString();
String code = uuid.substring(uuid.length() - 4);
ssoLoginInstructionsLabel.setText("Please wait while we open your browser and enter the code: " + code);
SSOCode.setText("Verification code: " + code);
ssoLoginInstructionsLabel.setText("After you login using the browser, you’ll be asked to enter the verification code above.");

AsyncProcessIcon asyncProcessIcon = new AsyncProcessIcon("Connecting...");
clearText(artifactoryUrl, xrayUrl, accessToken, username, password);
@@ -506,9 +510,10 @@ private void doSsoLogin() {
SSLContextBuilder.create().loadTrustMaterial(TrustAllStrategy.INSTANCE).build() :
serverConfig.getSslContext());

Thread.sleep(SSO_WAIT_BETWEEN_RETRIES_MILLIS);
accessManager.sendBrowserLoginRequest(uuid);
BrowserUtil.browse(removeEnd(platformUrl.getText(), "/") + "/ui/login?jfClientSession=" + uuid +
"&jfClientDisplayName=IDEA");
"&jfClientName=IDEA&jfClientCode=1");

for (int i = 0; i < SSO_RETRIES; i++) {
CreateAccessTokenResponse response = accessManager.getBrowserLoginRequestToken(uuid);