Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/client/mfa/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ func (c *CLIPrompt) Run(ctx context.Context, chal *proto.MFAAuthenticateChalleng
return nil, trace.Wrap(err)
}

// No prompt to run, no-op.
if !runOpts.PromptTOTP && !runOpts.PromptWebauthn {
return &proto.MFAAuthenticateResponse{}, nil
}

// Depending on the run opts, we may spawn a TOTP goroutine, webauth goroutine, or both.
spawnGoroutines := func(ctx context.Context, wg *sync.WaitGroup, respC chan<- MFAGoroutineResponse) {
// Use variables below to cancel OTP reads and make sure the goroutine exited.
Expand Down
5 changes: 5 additions & 0 deletions lib/client/mfa/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ func TestCLIPrompt(t *testing.T) {
expectResp *proto.MFAAuthenticateResponse
}{
{
name: "OK empty challenge",
expectStdOut: "",
challenge: &proto.MFAAuthenticateChallenge{},
expectResp: &proto.MFAAuthenticateResponse{},
}, {
name: "OK webauthn",
expectStdOut: "Tap any security key\n",
challenge: &proto.MFAAuthenticateChallenge{
Expand Down
8 changes: 4 additions & 4 deletions lib/client/mfa/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ func (c PromptConfig) GetRunOptions(ctx context.Context, chal *proto.MFAAuthenti
promptTOTP := chal.TOTP != nil
promptWebauthn := chal.WebauthnChallenge != nil

if !promptTOTP && !promptWebauthn {
return RunOpts{}, trace.BadParameter("mfa challenge is empty")
}

// Does the current platform support hardware MFA? Adjust accordingly.
switch {
case !promptTOTP && !c.WebauthnSupported:
Expand Down Expand Up @@ -161,5 +157,9 @@ func HandleMFAPromptGoroutines(ctx context.Context, startGoroutines func(context
return resp.Resp, nil
}

if len(errs) == 0 {
return &proto.MFAAuthenticateResponse{}, nil
}

return nil, trace.Wrap(trace.NewAggregate(errs...), "failed to authenticate using available MFA devices")
}
5 changes: 5 additions & 0 deletions lib/teleterm/daemon/mfaprompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ func (p *mfaPrompt) Run(ctx context.Context, chal *proto.MFAAuthenticateChalleng
return nil, trace.Wrap(err)
}

// No prompt to run, no-op.
if !runOpts.PromptTOTP && !runOpts.PromptWebauthn {
return &proto.MFAAuthenticateResponse{}, nil
}

// Depending on the run opts, we may spawn a TOTP goroutine, webauth goroutine, or both.
spawnGoroutines := func(ctx context.Context, wg *sync.WaitGroup, respC chan<- libmfa.MFAGoroutineResponse) {
ctx, cancel := context.WithCancelCause(ctx)
Expand Down