Skip to content

Commit

Permalink
SSH requesting access message (#137)
Browse files Browse the repository at this point in the history
This PR makes two changes to the status messages we use for SSH requests
in the CLI.

1. Replaces the "Requesting access" status message with a more generic
"Checking for access in P0"
2. Adds the message "Existing access found. Connecting to node." in the
scenario where a user had access approved previously and is waiting to
be connected to the node. Previously we showed nothing.

This only affects `p0 ssh <destination>` and `p0 scp <destination>`. It
does not affect any `p0 request` flows.

Before:


https://github.com/user-attachments/assets/cc0fce18-ab55-4074-af16-14a43a6ce06f


After:


https://github.com/user-attachments/assets/3c31ae41-437f-4328-a798-096710515dcc



Addresses:
https://linear.app/p0-security/issue/ENG-2827/requesting-access-spinner-is-displayed-when-it-shouldnt

---------

Co-authored-by: Gergely Dányi <gergas3@gmail.com>
  • Loading branch information
MichaelDimitras and gergas3 authored Nov 1, 2024
1 parent e8ac21a commit 00f0a06
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/commands/shared/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,22 @@ export const request =
}>,
authn?: Authn,
options?: {
accessMessage?: string;
message?: "all" | "approval-required" | "none";
}
): Promise<RequestResponse<T> | undefined> => {
const resolvedAuthn = authn ?? (await authenticate());
const { userCredential } = resolvedAuthn;
const accessMessage = (message?: string) => {
switch (message) {
case "approval-required":
return "Checking for access in P0";
default:
return "Requesting access";
}
};
const data = await spinUntil(
"Requesting access",
accessMessage(options?.message),
fetchCommand<RequestResponse<T>>(resolvedAuthn, args, [
command,
...args.arguments,
Expand Down
1 change: 1 addition & 0 deletions src/commands/shared/ssh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export const provisionRequest = async (
}
const { id, isPreexisting } = response;
if (!isPreexisting) print2("Waiting for access to be provisioned");
else print2("Existing access found. Connecting to instance.");

const provisionedRequest = await waitForProvisioning<PluginSshRequest>(
authn,
Expand Down

0 comments on commit 00f0a06

Please sign in to comment.