Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSH requesting access message #137

Conversation

MichaelDimitras
Copy link
Contributor

@MichaelDimitras MichaelDimitras commented Oct 31, 2024

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:

4333.mov

After:

11111.mov

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

@MichaelDimitras MichaelDimitras marked this pull request as ready for review October 31, 2024 18:58
message?: "all" | "approval-required" | "none";
}
): Promise<RequestResponse<T> | undefined> => {
const resolvedAuthn = authn ?? (await authenticate());
const { userCredential } = resolvedAuthn;
const data = await spinUntil(
"Requesting access",
options?.accessMessage ? options.accessMessage : "Requesting access",
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be dependent on the type union? "all" | "approval-required" | "none"

So if we see: "approval-required" we can still say: "requesting access" 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since "approval-required" is hardcoded for the ssh session request, I don't think we can use it to change the message in this case. I think the request would still have approval-required even if the user already had been approved in the past?

https://github.com/p0-security/p0cli/pull/137/files#diff-c16738fe5df540e2a49c613e959ebaa27241c6ce8389095b737f76c65bc44f8eL125

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, I see 🤔 .

Copy link
Contributor

Choose a reason for hiding this comment

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

You can make it dependent like this:

const accessMessage = (message?: string) => {
  switch (message) {
    case "approval-required":
      return "Requesting access";
    default:
      return "Requesting access";
  }
};

then here

Suggested change
options?.accessMessage ? options.accessMessage : "Requesting access",
accessMessage(options?.message),,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made this change, but the "approval-required" message type will return an accessMessage of Checking for access in P0.

This makes this change apply to p0 kubeconfig as well which I think is desirable since it's similar flow to starting an ssh session.

const accessMessage = (message?: string) => {
  switch (message) {
    case "approval-required":
     return "Checking for access in P0";;
    default:
      return "Requesting access";
  }
};

src/commands/shared/ssh.ts Outdated Show resolved Hide resolved
message?: "all" | "approval-required" | "none";
}
): Promise<RequestResponse<T> | undefined> => {
const resolvedAuthn = authn ?? (await authenticate());
const { userCredential } = resolvedAuthn;
const data = await spinUntil(
"Requesting access",
options?.accessMessage ? options.accessMessage : "Requesting access",
Copy link
Contributor

Choose a reason for hiding this comment

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

You can make it dependent like this:

const accessMessage = (message?: string) => {
  switch (message) {
    case "approval-required":
      return "Requesting access";
    default:
      return "Requesting access";
  }
};

then here

Suggested change
options?.accessMessage ? options.accessMessage : "Requesting access",
accessMessage(options?.message),,

MichaelDimitras and others added 3 commits October 31, 2024 12:56
Co-authored-by: Gergely Dányi <gergas3@gmail.com>
…isplayed-when-it-shouldnt' of github.com:p0-security/p0cli into michaeldimitras/eng-2827-requesting-access-spinner-is-displayed-when-it-shouldnt
@MichaelDimitras MichaelDimitras merged commit 00f0a06 into main Nov 1, 2024
3 checks passed
@MichaelDimitras MichaelDimitras deleted the michaeldimitras/eng-2827-requesting-access-spinner-is-displayed-when-it-shouldnt branch November 1, 2024 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants