-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…1416) * tshd events: Wait for listeners before responding When tshd is sending the relogin event, it needs to be able to know when the Electron app has finished relogging the user. I wanted to implement this by simply waiting for the response from the RPC. I'm so glad we did not use gRPC streams for tshd events as this would be much harder to implement with streams. * Return a function from ModalsService.openDialog which closes dialog With the introduction of important and regular modals, this will help us close the specific dialog if need arises. * Make tshd events listeners aware of request cancellation This will be useful in the upcoming commits. Basically, tshd is going to ask the Electron app to relogin the user, with a 1 minute timeout. The Electron app will show a login modal but if the user doesn't submit it within 1 minute, tshd is going to cancel the request. In that situation, we need to be able to close the modal. * Add support for passing reason in DialogClusterConnect * Add support for important modals This will let us show the relogin modal on expired cert, even if the user was using some other modal at that moment. * Remove title attr from notification text The user can read more by expanding the notification. The title attribute persisted even after expanding the notification, making reading it harder. * Add WindowsManager.forceFocusWindow * Use IAppContext instead of AppContext The next commit is going to add a private method to AppContext. IAppContext is an interface which enables us to pass a mocked version of AppContext in tests. That mock is not going have that private method, so any place accepting AppContext wouldn't be able to accept the mocked AppContext. Instead, classes & functions should accept IAppContext rather than AppContext. * Implement handlers for new tshd events tshd needs to be able to do two things: - Ask the user to log in again. - Forward errors from goroutines running gateways to the Electron app in form of a notification. Otherwise those error would be visible only in the logs. * Don't restart gateways after logging in Restarting the gateways on login was a workaround from times where gateways didn't manage their own certs. In the new flow, a gateway takes care of refreshing the certs itself through the middleware passed to alpnproxy.LocalProxy. syncRootClusterAndRestartClusterGatewaysAndCatchErrors used to call two functions: - syncRootClusterAndCatchErrors - restartClusterGatewaysAndCatchErrors The second function is no longer necessary, so we can make any place that was calling syncRootClusterAndRestartClusterGatewaysAndCatchErrors call just syncRootClusterAndCatchErrors instead.
- Loading branch information
Showing
38 changed files
with
1,814 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ function initializeApp(): void { | |
logger, | ||
configService, | ||
fileStorage, | ||
windowsManager, | ||
}); | ||
|
||
app.on( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { MainProcessClient } from 'teleterm/types'; | ||
import { ReloginRequest } from 'teleterm/services/tshdEvents'; | ||
import { | ||
ModalsService, | ||
ClusterConnectReason, | ||
} from 'teleterm/ui/services/modals'; | ||
import { ClustersService } from 'teleterm/ui/services/clusters'; | ||
|
||
export class ReloginService { | ||
constructor( | ||
private mainProcessClient: MainProcessClient, | ||
private modalsService: ModalsService, | ||
private clustersService: ClustersService | ||
) {} | ||
|
||
relogin( | ||
request: ReloginRequest, | ||
onRequestCancelled: (callback: () => void) => void | ||
): Promise<void> { | ||
this.mainProcessClient.forceFocusWindow(); | ||
let reason: ClusterConnectReason; | ||
|
||
if (request.gatewayCertExpired) { | ||
const gateway = this.clustersService.findGateway( | ||
request.gatewayCertExpired.gatewayUri | ||
); | ||
reason = { | ||
kind: 'reason.gateway-cert-expired', | ||
targetUri: request.gatewayCertExpired.targetUri, | ||
gateway: gateway, | ||
}; | ||
} | ||
|
||
return new Promise((resolve, reject) => { | ||
// GatewayCertReissuer in tshd makes sure that we only ever have one concurrent request to the | ||
// relogin event. So at the moment, ReloginService won't ever call openImportantDialog twice. | ||
const { closeDialog } = this.modalsService.openImportantDialog({ | ||
kind: 'cluster-connect', | ||
clusterUri: request.rootClusterUri, | ||
reason, | ||
onSuccess: () => resolve(), | ||
onCancel: () => | ||
reject(new Error('Login process was canceled by the user')), | ||
}); | ||
|
||
onRequestCancelled(closeDialog); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 31 additions & 14 deletions
45
web/packages/teleterm/src/services/tshd/v1/tshd_events_service_grpc_pb.d.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.