@@ -448,7 +448,7 @@ export default class RemoteConnector extends Disposable {
448
448
449
449
// From https://github.com/openssh/openssh-portable/blob/acb2059febaddd71ee06c2ebf63dcf211d9ab9f2/sshconnect2.c#L1689-L1690
450
450
private async getIdentityKeys ( hostConfig : Record < string , string > ) {
451
- const identityFiles : string [ ] = ( ( hostConfig [ 'IdentityFile' ] as unknown as string [ ] ) || [ ] ) . map ( untildify ) ;
451
+ const identityFiles : string [ ] = ( ( hostConfig [ 'IdentityFile' ] as unknown as string [ ] ) || [ ] ) . map ( untildify ) . map ( i => i . replace ( / \. p u b $ / , '' ) ) ;
452
452
if ( identityFiles . length === 0 ) {
453
453
identityFiles . push ( ...DEFAULT_IDENTITY_FILES ) ;
454
454
}
@@ -736,21 +736,25 @@ export default class RemoteConnector extends Disposable {
736
736
throw new Error ( 'SSH password modal dialog, Canceled' ) ;
737
737
}
738
738
739
- private async getGitpodSession ( gitpodHost : string , flow : UserFlowTelemetry ) {
739
+ private async ensureValidGitpodHost ( gitpodHost : string , flow : UserFlowTelemetry ) : Promise < boolean > {
740
740
const config = vscode . workspace . getConfiguration ( 'gitpod' ) ;
741
741
const currentGitpodHost = config . get < string > ( 'host' ) ! ;
742
742
if ( new URL ( gitpodHost ) . host !== new URL ( currentGitpodHost ) . host ) {
743
743
const yes = 'Yes' ;
744
744
const cancel = 'Cancel' ;
745
745
const action = await this . notifications . showInformationMessage ( `Connecting to a Gitpod workspace in '${ gitpodHost } '. Would you like to switch from '${ currentGitpodHost } ' and continue?` , { id : 'switch_gitpod_host' , flow } , yes , cancel ) ;
746
746
if ( action === cancel ) {
747
- return ;
747
+ return false ;
748
748
}
749
749
750
750
await config . update ( 'host' , gitpodHost , vscode . ConfigurationTarget . Global ) ;
751
751
this . logger . info ( `Updated 'gitpod.host' setting to '${ gitpodHost } ' while trying to connect to a Gitpod workspace` ) ;
752
752
}
753
753
754
+ return true ;
755
+ }
756
+
757
+ private async getGitpodSession ( gitpodHost : string ) {
754
758
const gitpodVersion = await getGitpodVersion ( gitpodHost , this . logger ) ;
755
759
const sessionScopes = [ 'function:getWorkspace' , 'function:getOwnerToken' , 'function:getLoggedInUser' , 'resource:default' ] ;
756
760
if ( await isOauthInspectSupported ( gitpodHost ) || isFeatureSupported ( gitpodVersion , 'SSHPublicKeys' ) /* && isFeatureSupported('', 'sendHeartBeat') */ ) {
@@ -780,7 +784,12 @@ export default class RemoteConnector extends Disposable {
780
784
return ;
781
785
}
782
786
783
- const session = await this . getGitpodSession ( params . gitpodHost , sshFlow ) ;
787
+ const isGitpodHostValid = await this . ensureValidGitpodHost ( params . gitpodHost , sshFlow ) ;
788
+ if ( ! isGitpodHostValid ) {
789
+ return ;
790
+ }
791
+
792
+ const session = await this . getGitpodSession ( params . gitpodHost ) ;
784
793
if ( ! session ) {
785
794
return ;
786
795
}
@@ -790,7 +799,7 @@ export default class RemoteConnector extends Disposable {
790
799
791
800
const forceUseLocalApp = getServiceURL ( params . gitpodHost ) === 'https://gitpod.io'
792
801
? ( await this . experiments . get < boolean > ( 'gitpod.remote.useLocalApp' , session . account . id , { gitpodHost : params . gitpodHost } ) ) !
793
- : ( await this . experiments . get < boolean > ( 'gitpod.remote.useLocalApp' , session . account . id , { gitpodHost : params . gitpodHost } , 'gitpod_remote_useLocalApp_sh' ) ) !
802
+ : ( await this . experiments . get < boolean > ( 'gitpod.remote.useLocalApp' , session . account . id , { gitpodHost : params . gitpodHost } , 'gitpod_remote_useLocalApp_sh' ) ) ! ;
794
803
const userOverride = String ( isUserOverrideSetting ( 'gitpod.remote.useLocalApp' ) ) ;
795
804
let sshDestination : string | undefined ;
796
805
if ( ! forceUseLocalApp ) {
@@ -892,14 +901,19 @@ export default class RemoteConnector extends Disposable {
892
901
}
893
902
894
903
public async autoTunnelCommand ( gitpodHost : string , instanceId : string , enabled : boolean ) {
895
- const forceUseLocalApp = vscode . workspace . getConfiguration ( 'gitpod' ) . get < boolean > ( 'remote.useLocalApp' ) ! ;
896
- if ( ! forceUseLocalApp ) {
897
- const authority = vscode . Uri . parse ( gitpodHost ) . authority ;
898
- const configKey = `config/${ authority } ` ;
899
- const localAppconfig = this . context . globalState . get < LocalAppConfig > ( configKey ) ;
900
- if ( ! localAppconfig || checkRunning ( localAppconfig . pid ) !== true ) {
901
- // Do nothing if we are using SSH gateway and local app is not running
902
- return ;
904
+ const session = await this . getGitpodSession ( gitpodHost ) ;
905
+ if ( session ) {
906
+ const forceUseLocalApp = getServiceURL ( gitpodHost ) === 'https://gitpod.io'
907
+ ? ( await this . experiments . get < boolean > ( 'gitpod.remote.useLocalApp' , session . account . id , { gitpodHost } ) ) !
908
+ : ( await this . experiments . get < boolean > ( 'gitpod.remote.useLocalApp' , session . account . id , { gitpodHost } , 'gitpod_remote_useLocalApp_sh' ) ) ! ;
909
+ if ( ! forceUseLocalApp ) {
910
+ const authority = vscode . Uri . parse ( gitpodHost ) . authority ;
911
+ const configKey = `config/${ authority } ` ;
912
+ const localAppconfig = this . context . globalState . get < LocalAppConfig > ( configKey ) ;
913
+ if ( ! localAppconfig || checkRunning ( localAppconfig . pid ) !== true ) {
914
+ // Do nothing if we are using SSH gateway and local app is not running
915
+ return ;
916
+ }
903
917
}
904
918
}
905
919
@@ -944,7 +958,7 @@ export default class RemoteConnector extends Disposable {
944
958
} catch ( e ) {
945
959
if ( e instanceof NoSyncStoreError ) {
946
960
const addSyncProvider = 'Settings Sync: Enable Sign In with Gitpod' ;
947
- const action = await this . notifications . showInformationMessage ( `Could not install local extensions on remote workspace. Please enable [Settings Sync](https://www.gitpod.io/docs/ides-and-editors/settings-sync#enabling-settings-sync-in-vs-code-desktop) with Gitpod.` , { flow, id : 'no_sync_store' } , addSyncProvider ) ;
961
+ const action = await this . notifications . showInformationMessage ( `Could not install local extensions on remote workspace. Please enable [Settings Sync](https://www.gitpod.io/docs/ides-and-editors/settings-sync#enabling-settings-sync-in-vs-code-desktop) with Gitpod.` , { flow, id : 'no_sync_store' } , addSyncProvider ) ;
948
962
if ( action === addSyncProvider ) {
949
963
vscode . commands . executeCommand ( 'gitpod.syncProvider.add' ) ;
950
964
}
@@ -1025,13 +1039,11 @@ export default class RemoteConnector extends Disposable {
1025
1039
if ( ! connectionInfo ) {
1026
1040
return ;
1027
1041
}
1028
- const gitpodVersion = await getGitpodVersion ( connectionInfo . gitpodHost , this . logger ) ;
1029
- const initRemoteFlow : UserFlowTelemetry = { ...connectionInfo , gitpodVersion : gitpodVersion . raw , flow : 'init_remote' } ;
1030
- const session = await this . getGitpodSession ( connectionInfo . gitpodHost , initRemoteFlow ) ;
1042
+
1043
+ const session = await this . getGitpodSession ( connectionInfo . gitpodHost ) ;
1031
1044
if ( ! session ) {
1032
1045
return ;
1033
1046
}
1034
- initRemoteFlow . userId = session . account . id ;
1035
1047
1036
1048
const workspaceInfo = await withServerApi ( session . accessToken , connectionInfo . gitpodHost , service => service . server . getWorkspace ( connectionInfo . workspaceId ) , this . logger ) ;
1037
1049
if ( workspaceInfo . latestInstance ?. status ?. phase !== 'running' ) {
@@ -1045,18 +1057,18 @@ export default class RemoteConnector extends Disposable {
1045
1057
1046
1058
await this . context . globalState . update ( `${ RemoteConnector . SSH_DEST_KEY } ${ sshDestStr } ` , { ...connectionInfo , isFirstConnection : false } ) ;
1047
1059
1060
+ const gitpodVersion = await getGitpodVersion ( connectionInfo . gitpodHost , this . logger ) ;
1061
+
1048
1062
const heartbeatSupported = session . scopes . includes ( ScopeFeature . LocalHeartbeat ) ;
1049
1063
if ( heartbeatSupported ) {
1050
1064
this . startHeartBeat ( session . accessToken , connectionInfo , gitpodVersion ) ;
1051
1065
} else {
1052
1066
this . logger . warn ( `Local heartbeat not supported in ${ connectionInfo . gitpodHost } , using version ${ gitpodVersion . raw } ` ) ;
1053
1067
}
1054
1068
1055
- const syncExtensions = ( await this . experiments . get < boolean > ( 'gitpod.remote.syncExtensions' , session . account . id , {
1056
- gitpodHost : connectionInfo . gitpodHost
1057
- } ) ) ! ;
1069
+ const syncExtensions = ( await this . experiments . get < boolean > ( 'gitpod.remote.syncExtensions' , session . account . id , { gitpodHost : connectionInfo . gitpodHost } ) ) ! ;
1058
1070
const userOverride = String ( isUserOverrideSetting ( 'gitpod.remote.syncExtensions' ) ) ;
1059
- const syncExtFlow = { ...initRemoteFlow , flow : 'sync_local_extensions' , userOverride } ;
1071
+ const syncExtFlow = { ...connectionInfo , gitpodVersion : gitpodVersion . raw , userId : session . account . id , flow : 'sync_local_extensions' , userOverride } ;
1060
1072
this . telemetry . sendUserFlowStatus ( syncExtensions ? 'enabled' : 'disabled' , syncExtFlow ) ;
1061
1073
if ( syncExtensions ) {
1062
1074
this . initializeRemoteExtensions ( syncExtFlow ) ;
0 commit comments