Add a null check to getMfaChallengeResponse#50570
Conversation
Why the app access bug is present on branch/v17 but not on masterAs discussed on Slack, on branch/v17, the faulty On master, that function is not called at all and the code for handling MFA returns early if Detailsteleport/web/packages/teleport/src/AppLauncher/AppLauncher.tsx Lines 121 to 123 in f9b61a0 teleport/web/packages/teleport/src/lib/useMfa.ts Lines 86 to 90 in f9b61a0 Broken password change flow with
|
ravicious
left a comment
There was a problem hiding this comment.
This fixes the problem on v17.
I wanted to suggest adding some tests, but SSO MFA is going to land in v17 and useMfa already has tests for when MFA is not required.
Since strict null checks are not enabled, another option to guarantee that the "no MFA challenge" is always handled would be to use a discriminated union, e.g. { kind: 'no-challenge' } | { kind: 'challenge', foo: Bar }. This would also help with adding null checks "just in case", as functions that actually need to work on a challenge could accept only the union variant with the challenge.
It's tempting to use { required: false } | { required: true, foo: Bar }. Unfortunately, discriminated unions on boolean fields don't work well with strict null checks turned off.
* Add a null check to getMfaChallengeResponse. * Add other null checks, just in case. * Update signatures to include undefined, consistently return undefined --------- Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>
Changelog: Fixed a bug in the WebUI that could cause an access denied error when accessing application.
Fix a bug caused by #49679 which was meant to check for null/undefined.
Closes #50556