Skip to content

Commit

Permalink
Review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
avatus committed Oct 25, 2024
1 parent 5e7a02e commit 3a52927
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion web/packages/teleport/src/lib/EventEmitterMfaSender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class EventEmitterMfaSender extends EventEmitter {
throw new Error('Not implemented');
}

// TODO (avatus) DELETE IN 19
// TODO (avatus) DELETE IN 18
/**
* @deprecated Use sendChallengeResponse instead.
*/
Expand Down
2 changes: 1 addition & 1 deletion web/packages/teleport/src/lib/tdp/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ export default class Client extends EventEmitterMfaSender {
try {
const mfaJson = this.codec.decodeMfaJson(buffer);
if (mfaJson.mfaType == 'n') {
this.emit(TermEvent.WEBAUTHN_CHALLENGE, mfaJson.jsonString);
this.emit(TermEvent.MFA_CHALLENGE, mfaJson.jsonString);
} else {
// mfaJson.mfaType === 'u', or else decodeMfaJson would have thrown an error.
this.handleError(
Expand Down
2 changes: 1 addition & 1 deletion web/packages/teleport/src/lib/term/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export enum TermEvent {
SESSION = 'terminal.new_session',
DATA = 'terminal.data',
CONN_CLOSE = 'connection.close',
WEBAUTHN_CHALLENGE = 'terminal.webauthn',
MFA_CHALLENGE = 'terminal.webauthn',
LATENCY = 'terminal.latency',
KUBE_EXEC = 'terminal.kube_exec',
}
Expand Down
4 changes: 2 additions & 2 deletions web/packages/teleport/src/lib/term/protobuf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const MessageTypeEnum = {
RESIZE: 'w',
FILE_TRANSFER_REQUEST: 'f',
FILE_TRANSFER_DECISION: 't',
WEBAUTHN_CHALLENGE: 'n',
MFA_CHALLENGE: 'n',
ERROR: 'e',
LATENCY: 'l',
KUBE_EXEC: 'k',
Expand Down Expand Up @@ -59,7 +59,7 @@ export const messageFields = {
data: MessageTypeEnum.RAW.charCodeAt(0),
event: MessageTypeEnum.AUDIT.charCodeAt(0),
close: MessageTypeEnum.SESSION_END.charCodeAt(0),
challengeResponse: MessageTypeEnum.WEBAUTHN_CHALLENGE.charCodeAt(0),
challengeResponse: MessageTypeEnum.MFA_CHALLENGE.charCodeAt(0),
kubeExec: MessageTypeEnum.KUBE_EXEC.charCodeAt(0),
error: MessageTypeEnum.ERROR.charCodeAt(0),
},
Expand Down
8 changes: 4 additions & 4 deletions web/packages/teleport/src/lib/term/tty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Tty extends EventEmitterMfaSender {
// but to be backward compatible, we need to still spread the existing webauthn only fields
// as "top level" fields so old proxies can still respond to webauthn challenges.
// in 19, we can just pass "data" without this extra step
// TODO (avatus): DELETE IN 19
// TODO (avatus): DELETE IN 18
const backwardCompatibleData = {
...data.webauthn_response,
...data,
Expand All @@ -101,7 +101,7 @@ class Tty extends EventEmitterMfaSender {
this.socket.send(bytearray);
}

// TODO (avatus) DELETE IN 19
// TODO (avatus) DELETE IN 18
/**
* @deprecated Use sendChallengeResponse instead.
*/
Expand Down Expand Up @@ -215,8 +215,8 @@ class Tty extends EventEmitterMfaSender {
const msg = this._proto.decode(uintArray);

switch (msg.type) {
case MessageTypeEnum.WEBAUTHN_CHALLENGE:
this.emit(TermEvent.WEBAUTHN_CHALLENGE, msg.payload);
case MessageTypeEnum.MFA_CHALLENGE:
this.emit(TermEvent.MFA_CHALLENGE, msg.payload);
break;
case MessageTypeEnum.AUDIT:
this._processAuditPayload(msg.payload);
Expand Down
9 changes: 3 additions & 6 deletions web/packages/teleport/src/lib/useMfa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export function useMfa(emitterSender: EventEmitterMfaSender): MfaState {

useEffect(() => {
let ssoChallengeAbortController: AbortController | undefined;
const chanllengeHandler = (challengeJson: string) => {
const challengeHandler = (challengeJson: string) => {
const { webauthnPublicKey, ssoChallenge, totpChallenge } =
makeMfaAuthenticateChallenge(challengeJson);

Expand All @@ -150,14 +150,11 @@ export function useMfa(emitterSender: EventEmitterMfaSender): MfaState {
}
};

emitterSender?.on(TermEvent.WEBAUTHN_CHALLENGE, chanllengeHandler);
emitterSender?.on(TermEvent.MFA_CHALLENGE, challengeHandler);

return () => {
ssoChallengeAbortController?.abort();
emitterSender?.removeListener(
TermEvent.WEBAUTHN_CHALLENGE,
chanllengeHandler
);
emitterSender?.removeListener(TermEvent.MFA_CHALLENGE, challengeHandler);
};
}, [emitterSender, waitForSsoChallengeResponse]);

Expand Down

0 comments on commit 3a52927

Please sign in to comment.