mirror of
https://github.com/microsoft/vscode.git
synced 2026-10-05 15:36:22 +01:00
tunnels: fixes to allow msa auth (#197259)
This commit is contained in:
1 parent
49b26d86b3
commit
b431ca92db
4 files changed
+17
-10
No files matched your search
@@ -360,7 +360,7 @@ pub async fn status(ctx: CommandContext) -> Result<i32, AnyError> {
|
||||
service_installed,
|
||||
tunnel: match tunnel {
|
||||
Ok(s) => Some(s),
|
||||
Err(CodeError::NoRunningTunnel) => None,
|
||||
Err(CodeError::NoRunningTunnel | CodeError::AsyncPipeFailed(_)) => None,
|
||||
Err(e) => return Err(e.into()),
|
||||
},
|
||||
})
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "code-oss-dev",
|
||||
"version": "1.85.0",
|
||||
"distro": "ff0198cd90b25ba7ca853279cea9b8bb3cf5164d",
|
||||
"distro": "a0ee56917203bf689ffe2821a7876cdcd5707200",
|
||||
"author": {
|
||||
"name": "Microsoft Corporation"
|
||||
},
|
||||
|
||||
@@ -268,10 +268,18 @@ export class RemoteTunnelService extends Disposable implements IRemoteTunnelServ
|
||||
|
||||
// split and find the line, since in dev builds additional noise is
|
||||
// added by cargo to the output.
|
||||
const status: {
|
||||
let status: {
|
||||
service_installed: boolean;
|
||||
tunnel: object | null;
|
||||
} = JSON.parse(output.trim().split('\n').find(l => l.startsWith('{'))!);
|
||||
};
|
||||
|
||||
try {
|
||||
status = JSON.parse(output.trim().split('\n').find(l => l.startsWith('{'))!);
|
||||
} catch (e) {
|
||||
this._logger.error(`Could not parse status output: ${JSON.stringify(output.trim())}`);
|
||||
this.setTunnelStatus(TunnelStates.disconnected());
|
||||
return;
|
||||
}
|
||||
|
||||
isServiceInstalled = status.service_installed;
|
||||
this._logger.info(status.tunnel ? 'Other tunnel running, attaching...' : 'No other tunnel running');
|
||||
|
||||
@@ -270,6 +270,9 @@ export class RemoteTunnelWorkbenchContribution extends Disposable implements IWo
|
||||
);
|
||||
}
|
||||
|
||||
private getPreferredTokenFromSession(session: ExistingSessionItem) {
|
||||
return session.session.accessToken || session.session.idToken;
|
||||
}
|
||||
|
||||
private async startTunnel(asService: boolean): Promise<ConnectionInfo | undefined> {
|
||||
if (this.connectionInfo) {
|
||||
@@ -327,7 +330,7 @@ export class RemoteTunnelWorkbenchContribution extends Disposable implements IWo
|
||||
break;
|
||||
}
|
||||
});
|
||||
const token = authenticationSession.session.idToken ?? authenticationSession.session.accessToken;
|
||||
const token = this.getPreferredTokenFromSession(authenticationSession);
|
||||
const account: IRemoteTunnelSession = { sessionId: authenticationSession.session.id, token, providerId: authenticationSession.providerId, accountLabel: authenticationSession.session.account.label };
|
||||
this.remoteTunnelService.startTunnel({ active: true, asService, session: account }).then(status => {
|
||||
if (!completed && (status.type === 'connected' || status.type === 'disconnected')) {
|
||||
@@ -352,10 +355,6 @@ export class RemoteTunnelWorkbenchContribution extends Disposable implements IWo
|
||||
|
||||
private async getAuthenticationSession(): Promise<ExistingSessionItem | undefined> {
|
||||
const sessions = await this.getAllSessions();
|
||||
if (sessions.length === 1) {
|
||||
return sessions[0];
|
||||
}
|
||||
|
||||
const quickpick = this.quickInputService.createQuickPick<ExistingSessionItem | AuthenticationProviderOption | IQuickPickItem>();
|
||||
quickpick.ok = false;
|
||||
quickpick.placeholder = localize('accountPreference.placeholder', "Sign in to an account to enable remote access");
|
||||
@@ -448,7 +447,7 @@ export class RemoteTunnelWorkbenchContribution extends Disposable implements IWo
|
||||
if (session) {
|
||||
const sessionItem = (await this.getAllSessions()).find(s => s.session.id === session.sessionId);
|
||||
if (sessionItem) {
|
||||
return sessionItem.session.idToken ?? sessionItem.session.accessToken;
|
||||
return this.getPreferredTokenFromSession(sessionItem);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
|
||||
Reference in new issue
Block a user