MFA for admin actions: Add MFA prompt to API client (tctl and tsh)#30203
MFA for admin actions: Add MFA prompt to API client (tctl and tsh)#30203
tctl and tsh)#30203Conversation
codingllama
left a comment
There was a problem hiding this comment.
Reviewed commit-by-commit, so some comments may be repeated (or already addressed).
First of all thanks for the refactor, moving client-MFA to its own package is a good idea.
I think overall the PR is too big, it would be easier to review a smaller, more gradual package move, with changes separate in their own PRs. If you want to break it up, given the number of comments, it might be a good idea. (You can preemptively address the comments in future PRs.)
|
One more reason to break the PR is so we can backport the package move, but not the admin changes. If we don't backport the move, any eventual fixes in older code will be nasty to get to old releases. |
23668a4 to
be6d7d5
Compare
codingllama
left a comment
There was a problem hiding this comment.
This is WAY simpler to review now, I didn't even recognize it at first. Many thanks for all the refactors.
a88ceaf to
e74b3e2
Compare
bac92d3 to
ef11149
Compare
e74b3e2 to
5d3ab0d
Compare
ef11149 to
22d2582
Compare
There was a problem hiding this comment.
Do we really want any and every client created to have this interceptor or just the tctl client? Should the client used by a node/app/db/kube/etc service have this interceptor included?
There was a problem hiding this comment.
I'd say yes, why would we not want it?
There was a problem hiding this comment.
How is the Proxy supposed to perform MFA?
There was a problem hiding this comment.
Oh sorry, I was thinking about the wrong PR. Ignore me.
There was a problem hiding this comment.
I've changed this so it is only used for tsh, tctl, and Teleport Connect.
The interceptor will always be set, but it'll essentially be a noop unless client.PromptAdminRequestMFA is set.
To be specific, it will aggregate trace.BadParameter("missing PromptAdminRequestMFA field, client cannot perform MFA ceremony") with the ErrAdminActionMFARequired passed through the interceptor.
@codingllama you mentioned before that you weren't sold on enabling/disabling the interceptor in this way, but I think it makes more sense. If the client has a method to prompt MFA, it should. If it doesn't, it shouldn't. Adding a separate flag seems redundant.
There was a problem hiding this comment.
How difficult would it be to create certain clients without the interceptor?
If you think it isn't worth it, or a worse solution, we can go with the nil. Thanks for calling attention to it explicitly.
There was a problem hiding this comment.
I think having the aggregated error is slightly better as it can help point us in the right direction with any bugs, such as if a client does not have PromptAdminRequestMFA set when we expect it to. Also adding the mfa-retry interceptor into the middle of list after the fact is a bit awkward from a code formatting perspective.
5b44fe1 to
5337fc4
Compare
e0e0490 to
5f869dc
Compare
2cd7148 to
93e7761
Compare
93e7761 to
aa9103a
Compare
aa9103a to
343d6d5
Compare
* Add MFA PerRPCredentials. * Add RetryWithMFA unary interceptor. * Add MFA prompt retry mechanism for Admin API requests.
aec9265 to
1b07967
Compare
tctl and tsh)tctl and tsh)
tctl and tsh)tctl and tsh)
This PR updates the API client to prompt for MFA for admin actions. This can be done either by passing the call option directly, or retrying after getting the relevant access denied error.
Part of implementing RFD 131.
In follow up PRs, Admin Action API requests will be updated to
This is used in
tctl,tsh, and Teleport Connect, though Teleport Connect does not show a modal yet.WebSessions do not use this retry mechanism. I follow up this PR with a solution for the WebUI if I find a way to do it.
Depends on #30578