Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
18 changes: 9 additions & 9 deletions src/openshift/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,15 +451,15 @@ export class Cluster extends OpenShiftItem {
@vsCommand('openshift.explorer.login.clipboard')
static async loginUsingClipboardToken(apiEndpointUrl: string, oauthRequestTokenUrl: string): Promise<string | null> {
const clipboard = await Cluster.readFromClipboard();
if(!clipboard) {
const choice = await window.showErrorMessage('Cannot parse token in clipboard. Please click `Get token` button below, copy token into clipboard and press `Login to Sandbox` button again.',
'Get token');
if (choice === 'Get token') {
await commands.executeCommand('vscode.open', Uri.parse(oauthRequestTokenUrl));
}
return;
}
return Cluster.tokenLogin(apiEndpointUrl, true, clipboard);
// if(!clipboard) {
// const choice = await window.showErrorMessage('Cannot parse token in clipboard. Please click `Get token` button below, copy token into clipboard and press `Login to Sandbox` button again.',
// 'Get token');
// if (choice === 'Get token') {
// await commands.executeCommand('vscode.open', Uri.parse(oauthRequestTokenUrl));
// }
// return;
// }
return Cluster.tokenLogin(apiEndpointUrl, true, oauthRequestTokenUrl);
}

static async loginUsingClipboardInfo(dashboardUrl: string): Promise<string | null> {
Expand Down
1 change: 1 addition & 0 deletions src/openshift/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface SBSignupResponse {
givenName: string;
status: SBStatus;
username: string;
proxyURL: string;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new attribute in reg service response

}

export interface SBResponseData {
Expand Down
11 changes: 7 additions & 4 deletions src/webview/cluster/app/sandboxView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export default function addSandboxView(props): JSX.Element {
consoleDashboard: '',
apiEndpoint: '',
oauthTokenEndpoint: '',
errorCode: undefined
errorCode: undefined,
proxyUrl: ''
});

const messageListener = (event) => {
Expand Down Expand Up @@ -151,7 +152,8 @@ export default function addSandboxView(props): JSX.Element {
statusInfo: currentState.statusInfo,
apiEndpoint: '',
oauthTokenEndpoint: '',
errorCode: undefined
errorCode: undefined,
proxyUrl: ''
});
postMessage('sandboxDetectStatus');
}
Expand Down Expand Up @@ -302,7 +304,8 @@ export default function addSandboxView(props): JSX.Element {
consoleDashboard: '',
apiEndpoint: '',
oauthTokenEndpoint: '',
errorCode: undefined
errorCode: undefined,
proxyUrl: ''
});
}

Expand Down Expand Up @@ -379,7 +382,7 @@ export default function addSandboxView(props): JSX.Element {
const Provisioned = () => {

const handleLoginButton = () => {
postMessage('sandboxLoginUsingDataInClipboard', {apiEndpointUrl: currentState.apiEndpoint, oauthRequestTokenUrl: `${currentState.oauthTokenEndpoint}/request`});
postMessage('sandboxLoginUsingDataInClipboard', {apiEndpointUrl: currentState.apiEndpoint, oauthRequestTokenUrl: `${currentState.oauthTokenEndpoint}/request`, proxyUrl: currentState.proxyUrl});
};

return (
Expand Down
4 changes: 2 additions & 2 deletions src/webview/cluster/clusterViewLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async function clusterEditorMessageListener (event: any ): Promise<any> {
} else {
if (signupStatus.status.ready) {
const oauthInfo = await sandboxAPI.getOauthServerInfo(signupStatus.apiEndpoint);
panel.webview.postMessage({action: 'sandboxPageProvisioned', statusInfo: signupStatus.username, consoleDashboard: signupStatus.consoleURL, apiEndpoint: signupStatus.apiEndpoint, oauthTokenEndpoint: oauthInfo.token_endpoint });
panel.webview.postMessage({action: 'sandboxPageProvisioned', statusInfo: signupStatus.username, consoleDashboard: signupStatus.consoleURL, apiEndpoint: signupStatus.apiEndpoint, oauthTokenEndpoint: oauthInfo.token_endpoint, proxyUrl: signupStatus.proxyURL });
} else {
// cluster is not ready and the reason is
if (signupStatus.status.verificationRequired) {
Expand Down Expand Up @@ -173,7 +173,7 @@ async function clusterEditorMessageListener (event: any ): Promise<any> {
case 'sandboxLoginUsingDataInClipboard':
const telemetryEventLoginToSandbox = new ExtCommandTelemetryEvent('openshift.explorer.addCluster.sandboxLoginUsingDataInClipboard');
try {
const result = await Cluster.loginUsingClipboardToken(event.payload.apiEndpointUrl, event.payload.oauthRequestTokenUrl);
const result = await Cluster.loginUsingClipboardToken(event.payload.proxyUrl, (sessionCheck as any).idToken);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Login to the sandbox using proxyUrl and token from RedHat SSO. No need to get sandbox token from browser.

if (result) vscode.window.showInformationMessage(`${result}`);
telemetryEventLoginToSandbox.send();
} catch (err) {
Expand Down