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

Remove CLI-based config options from Teleport Connect MFA prompts #47875

Merged
merged 2 commits into from
Oct 28, 2024

Conversation

Joerger
Copy link
Contributor

@Joerger Joerger commented Oct 23, 2024

Remove CLI-based config options from the Teleport Connect MFA prompts. This was previously preventing OTP in cases where it could be allowed.

Related: #46820 - if we replace the terminal prompt with the custom teleport connect prompt, totp would work now.

Depends on #47874

@Joerger Joerger changed the title Fix OTP prompt in Teleport Connect Remove CLI-based config options from Teleport Connect MFA prompts Oct 23, 2024
@Joerger Joerger changed the base branch from master to joerger/cli-prompt-refactor October 23, 2024 21:02
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-47875.d212ksyjt6y4yg.amplifyapp.com

Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-47875.d3pp5qlev8mo18.amplifyapp.com

@Joerger Joerger added the no-changelog Indicates that a PR does not require a changelog entry label Oct 23, 2024
@Joerger Joerger force-pushed the joerger/cli-prompt-refactor branch from a85d056 to c8d3827 Compare October 24, 2024 21:33
Base automatically changed from joerger/cli-prompt-refactor to master October 24, 2024 22:48
@Joerger Joerger force-pushed the joerger/fix-otp-teleport-connect branch from e32130b to 31b86bc Compare October 25, 2024 00:53
@Joerger Joerger marked this pull request as ready for review October 25, 2024 00:53
@github-actions github-actions bot requested review from gzdunek and ryanclark October 25, 2024 00:53
@Joerger Joerger mentioned this pull request Oct 25, 2024
@Joerger Joerger force-pushed the joerger/fix-otp-teleport-connect branch from 31b86bc to 33bf6b7 Compare October 25, 2024 01:00
@ravicious ravicious requested review from ravicious and removed request for ryanclark October 25, 2024 08:27
Copy link
Member

@ravicious ravicious left a comment

Choose a reason for hiding this comment

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

Both the login modal and the MFA check still allow me to select one of the two available options. 👍 Thanks for cleaning up those old comments!

Copy link
Member

Choose a reason for hiding this comment

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

I was about to forward #46820 to you and that's how I found this PR.

I don't think this is going to affect #46820 that much nor bring it closer to completion. I assume #46820 is purely about SSH as we show the regular MFA prompt for other resources.

When you SSH to a node, the Electron app executes tsh ssh underneath, without going through the tsh daemon. That tsh ssh process has no knowledge about the Electron app. Making it Electron-aware would likely require too much effort.

I think this could be solved in two ways. tsh could show some kind of prompt letting you choose which auth method you want to use. Historically, it seems that we eschewed that in favor of supplying a specific flag if someone wants to use OTP.

The other way to solve this would be to add a new config option to Connect (ssh.mfaMode?) that adds an appropriate flag to all tsh ssh invocations coming from Connect. The user wouldn't be able to set this flag per-resource or even per profile, but at least it'd unblock users who are not able to use OTP at the moment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do we think about replacing the terminal-based mfa prompt for SSH with the custom connect MFA prompt? It should be possible to inject the custom prompt in there, but I need to check.

Copy link
Member

Choose a reason for hiding this comment

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

I tried to explain why that's not hard to do in the third paragraph. ;) The MFA prompt for every other resource kind goes through tsh daemon, e.g., the Electron app tells tshd to create a local proxy, tshd attempts to generate a cert, lib/client code prompts for an MFA check and tshd forwards this to the Electron app.

SSH connections do not go through the tsh daemon, the Electron app just executes tsh ssh.

If there's some other way of doing it without forcing tsh ssh to be Electron-aware then that's something we can explore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tsh could show some kind of prompt letting you choose which auth method you want to use.

IIUC this is not something we want to do, as it requires us to set AllowStdinHijack=true so that tsh can accept input. We'd need to ask Alan for more details on what issues that can cause.

If there's some other way of doing it without forcing tsh ssh to be Electron-aware then that's something we can explore.

Regardless I think we want this to start with an Electron dialog window if possible, it's cleaner than trying to add a config option or prompt for stdin.

The first idea to come to mind is to add a new tshd request to check if MFA is required before running the tsh ssh command. If MFA is required, we could see what options are available to them (Webauthn, totp, sso) and present them with a diagog to choose one, e.g. by clicking one of 3 buttons. Then depending on what they click, we could run tsh ssh --mfa-mode=sso/otp/webauthn and let the cli prompt continue as normal. WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

This would be fine UX-wise, but has the unfortunate effect of degrading performance for people not using per-session MFA, which is something we've strived to avoid. I remember this being the case when Michael was working on MFA in file transfers in the Web UI, for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point. In that case we should let tsh ssh do it's thing, racing an MFA and non-MFA session and only prompting when needed.

Outside of making a whole new ssh for Connect implementation that utilizes tshd <-> Electron communication, we could experiment with other ways of having tshd/Electron communicate with tsh ssh.

For example, similar to our Teleport re-exec logic, we could pass a file descriptor to tsh ssh to handle back and forth communication with the Electron App. Over this file descriptor, tsh ssh could send a generic MFA prompt request when needed, just like to the request from tshd.

Or if a file descriptor isn't a viable solution (I don't know javascript limitations well), we could use a unix/tcp socket instead. Or maybe we could plug into the tshd socket from tsh ssh. e.g. tsh ssh --tshd=/path/to/socket.

@Joerger Joerger enabled auto-merge October 28, 2024 17:07
@Joerger Joerger added this pull request to the merge queue Oct 28, 2024
Merged via the queue into master with commit 7d313a6 Oct 28, 2024
43 of 44 checks passed
@Joerger Joerger deleted the joerger/fix-otp-teleport-connect branch October 28, 2024 17:43
@public-teleport-github-review-bot

@Joerger See the table below for backport results.

Branch Result
branch/v17 Create PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v17 no-changelog Indicates that a PR does not require a changelog entry size/sm ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants