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

Always issue relogin and per-session mfa requests for the root cluster URI #42355

Merged
merged 8 commits into from
Jun 5, 2024

Conversation

gzdunek
Copy link
Contributor

@gzdunek gzdunek commented Jun 4, 2024

I noticed that when we show the relogin dialog for a leaf resource, we say Log in to <leaf cluster>. I don't think it is correct behavior, since the user should log in to the root cluster, not the leaf one.
This doesn't seem to be only a visual thing, because if I continue and log in to that leaf, I get:
image
So I think we actually logged in to the leaf cluster and then tried to fetch leaf clusters for it.

What's more, we do the same thing for per-session MFA prompts. They say Verify your identity on <leaf cluster>. Although per-session MFA is controlled by a cluster setting (so it can be disabled on root and enabled on leaf) I think we should still show root cluster name there (and the proto field name suggests that as well). @Joerger, am I correct?

@gzdunek gzdunek added teleport-connect Issues related to Teleport Connect. backport/branch/v14 no-changelog Indicates that a PR does not require a changelog entry backport/branch/v15 backport/branch/v16 labels Jun 4, 2024
@gzdunek gzdunek requested review from ravicious and Joerger June 4, 2024 13:21
@github-actions github-actions bot requested a review from nklaassen June 4, 2024 13:22
@gzdunek gzdunek removed the request for review from nklaassen June 4, 2024 13:22
@@ -370,7 +370,7 @@ func (s *Service) createGateway(ctx context.Context, params CreateGatewayParams)
// per-session MFA checks.
func (s *Service) reissueGatewayCerts(ctx context.Context, g gateway.Gateway) (tls.Certificate, error) {
reloginReq := &api.ReloginRequest{
RootClusterUri: g.TargetURI().GetClusterURI().String(),
RootClusterUri: g.TargetURI().GetRootClusterURI().String(),
Copy link
Member

Choose a reason for hiding this comment

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

This is correct, the relogin request should always use the URI of a root cluster. Otherwise the login modal targets a leaf cluster (but through the root cluster, not directly) and I'm not sure what really happens there.

Perhaps the handlers for login should also verify if they received URI to a root cluster rather than a leaf?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps the handlers for login should also verify if they received URI to a root cluster rather than a leaf?

Good idea, added.

@@ -125,7 +126,7 @@ func (p *mfaPrompt) promptWebauthn(ctx context.Context, chal *proto.MFAAuthentic

func (p *mfaPrompt) promptMFA(ctx context.Context, chal *proto.MFAAuthenticateChallenge, runOpts libmfa.RunOpts) (*proto.MFAAuthenticateResponse, error) {
resp, err := p.promptAppMFA(ctx, &api.PromptMFARequest{
RootClusterUri: p.clusterURI,
RootClusterUri: p.resourceURI.GetRootClusterURI().String(),
Copy link
Member

Choose a reason for hiding this comment

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

This I'm not 100% sure about. Based on the modal implementation, this field is used purely for display only, unlike cluster URI in the login modal.

We might ask the user to authenticate an action that's related to a leaf resource. It's also good to know which cluster the given resource belongs to.

OTOH, the authentication step always happens in the root cluster. As in, we shouldn't make the user think that there's a separate set of devices for authenticating in root clusters and a separate set for leaf clusters. Also, we always show the modal after the user performs an action. It shouldn't ever catch someone by surprise. So I suppose they'll have a good idea as to which resource they're trying to access.

I think it'd be best if the modal said something like:

Verify your identity on [root cluster]

MFA is required to access Kubernetes cluster "minikube" from leaf cluster [leaf cluster]

This would require passing ClusterUri instead and adding some conditional logic to the modal. However, I think for now it's fine if we always show the root cluster name in the title of the modal.

For reference, this is how the modal looks like:

verify-identity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OTOH, the authentication step always happens in the root cluster. As in, we shouldn't make the user think that there's a separate set of devices for authenticating in root clusters and a separate set for leaf clusters.

Yeah, that was my reasoning.

Also, we always show the modal after the user performs an action. It shouldn't ever catch someone by surprise. So I suppose they'll have a good idea as to which resource they're trying to access.

Actually, it may catch you by surprise. If you had a few tabs open that required per-session MFA , and you reopen the previous session, you will see an MFA pop-up for each of them, one after another. So perhaps I will change rootClusterUri to clusterUri in the proto message and handle it in the dialog? It doesn't seem to be too much work.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good.

@gzdunek gzdunek requested a review from ravicious June 4, 2024 15:30
@@ -83,6 +88,11 @@ func (s *Handler) LoginPasswordless(stream api.TerminalService_LoginPasswordless
if err != nil {
return trace.Wrap(err)
}

if !cluster.URI.IsRoot() {
return trace.BadParameter("cluster URI must be a root URI")
Copy link
Member

Choose a reason for hiding this comment

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

That's fine for now, but in a completely new code it'd have been better to convert the string into uri.ResourceURI, then check if it points to a root cluster and only then call s.DaemonService.ResolveClusterURI.

gzdunek added 4 commits June 5, 2024 18:01
…-for-root-cluster

# Conflicts:
#	gen/proto/go/teleport/lib/teleterm/v1/tshd_events_service.pb.go
…-for-root-cluster

# Conflicts:
#	gen/proto/go/teleport/lib/teleterm/v1/tshd_events_service.pb.go
@gzdunek gzdunek added this pull request to the merge queue Jun 5, 2024
Merged via the queue into master with commit 282f6f0 Jun 5, 2024
41 checks passed
@gzdunek gzdunek deleted the gzdunek/relogin-and-session-mfa-for-root-cluster branch June 5, 2024 20:06
@public-teleport-github-review-bot

@gzdunek See the table below for backport results.

Branch Result
branch/v14 Failed
branch/v15 Failed
branch/v16 Failed

gzdunek added a commit that referenced this pull request Jun 6, 2024
…r URI (#42355)

* Always issue per-session MFA requests for a root cluster URI

* Always issue relogin requests for a root cluster URI

* Check if cluster URI is root cluster URI in login handlers

* Pass clusterUri instead of rootClusterUri to the ReAuthenticate dialog

* Reserve `root_cluster_uri` field too

* Resolve conflicts

(cherry picked from commit 282f6f0)
@public-teleport-github-review-bot

@gzdunek See the table below for backport results.

Branch Result
branch/v14 Failed
branch/v15 Failed
branch/v16 Failed

gzdunek added a commit that referenced this pull request Jun 7, 2024
…r URI (#42355)

* Always issue per-session MFA requests for a root cluster URI

* Always issue relogin requests for a root cluster URI

* Check if cluster URI is root cluster URI in login handlers

* Pass clusterUri instead of rootClusterUri to the ReAuthenticate dialog

* Reserve `root_cluster_uri` field too

* Resolve conflicts

(cherry picked from commit 282f6f0)
github-merge-queue bot pushed a commit that referenced this pull request Jun 7, 2024
…r URI (#42355) (#42605)

* Always issue per-session MFA requests for a root cluster URI

* Always issue relogin requests for a root cluster URI

* Check if cluster URI is root cluster URI in login handlers

* Pass clusterUri instead of rootClusterUri to the ReAuthenticate dialog

* Reserve `root_cluster_uri` field too

* Resolve conflicts

(cherry picked from commit 282f6f0)
github-merge-queue bot pushed a commit that referenced this pull request Jun 7, 2024
…cluster URI (#42606)

* Always issue relogin and per-session mfa requests for the root cluster URI (#42355)

* Always issue per-session MFA requests for a root cluster URI

* Always issue relogin requests for a root cluster URI

* Check if cluster URI is root cluster URI in login handlers

* Pass clusterUri instead of rootClusterUri to the ReAuthenticate dialog

* Reserve `root_cluster_uri` field too

* Resolve conflicts

(cherry picked from commit 282f6f0)

* Remove unnecessary type casts and add imports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v14 backport/branch/v15 backport/branch/v16 no-changelog Indicates that a PR does not require a changelog entry size/sm teleport-connect Issues related to Teleport Connect.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants