Skip to content

Commit

Permalink
Resolve comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joerger committed Dec 17, 2024
1 parent 7779b48 commit 99729ea
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
13 changes: 12 additions & 1 deletion lib/client/weblogin.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,18 @@ type SSOResponse struct {
// GetOptionalMFAResponseProtoReq converts response to a type proto.MFAAuthenticateResponse,
// if there were any responses set. Otherwise returns nil.
func (r *MFAChallengeResponse) GetOptionalMFAResponseProtoReq() (*proto.MFAAuthenticateResponse, error) {
if r.TOTPCode != "" && r.WebauthnResponse != nil && r.SSOResponse != nil {
var availableResponses int
if r.TOTPCode != "" {
availableResponses++
}
if r.WebauthnResponse != nil {
availableResponses++
}
if r.SSOResponse != nil {
availableResponses++
}

if availableResponses > 1 {
return nil, trace.BadParameter("only one MFA response field can be set")
}

Expand Down
4 changes: 3 additions & 1 deletion lib/web/mfa.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@ func (h *Handler) createAuthenticateChallengeHandle(w http.ResponseWriter, r *ht
return nil, trace.Wrap(err)
}
channelID := id.String()
ssoClientRedirectURL.RawQuery = url.Values{"channel_id": {channelID}}.Encode()
query := ssoClientRedirectURL.Query()
query.Set("channel_id", channelID)
ssoClientRedirectURL.RawQuery = query.Encode()

chal, err := clt.CreateAuthenticateChallenge(r.Context(), &proto.CreateAuthenticateChallengeRequest{
Request: &proto.CreateAuthenticateChallengeRequest_ContextUser{
Expand Down
9 changes: 7 additions & 2 deletions web/packages/teleport/src/Console/DocumentSsh/DocumentSsh.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,13 @@ function DocumentSsh({ doc, visible }: PropTypes) {

useEffect(() => {
// when switching tabs or closing tabs, focus on visible terminal
terminalRef.current?.focus();
}, [visible, ftMfa.challenge]);
if (
ttyMfa.attempt.status === 'processing' ||
ftMfa.attempt.status === 'processing'
) {
terminalRef.current?.focus();
}
}, [visible, ttyMfa.attempt.status, ftMfa.attempt.status]);

const onSearchClose = useCallback(() => {
setShowSearch(false);
Expand Down

0 comments on commit 99729ea

Please sign in to comment.