Skip to content

WebUI MFA types refactor#49678

Merged
Joerger merged 10 commits intomasterfrom
joerger/unify-mfa-types
Dec 9, 2024
Merged

WebUI MFA types refactor#49678
Joerger merged 10 commits intomasterfrom
joerger/unify-mfa-types

Conversation

@Joerger
Copy link
Copy Markdown
Contributor

@Joerger Joerger commented Dec 3, 2024

Changes:

  • Move, deduplicate, and add MFA types to web/packages/teleport/src/services/mfa
    • Also rename some types/methods and improve type assertions.
  • Refactor MFA options to be derived from MFA challenges rather than listed devices, which is more reliable (backend logic) and removes the need for a lot of extra logic we were doing based off of auth2faType

Prerequisite for SSO MFA changes (TODO).

TODO: Follow up PRs to remove remaining uses of createMfaOptions.

};
}

return opt as MfaOption;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Isn't opt already MfaOption here?

Copy link
Copy Markdown
Contributor Author

@Joerger Joerger Dec 3, 2024

Choose a reason for hiding this comment

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

It's of type services/mfa/MfaOption but this method needs to return utils/MfaOption. I'm not sure how to how to make the former a type alias of the latter since they have the same name, so I just did a type cast. Is there another way to make this work?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

would using satisfies MfaOption work here to coerce it w/out asserting?

Copy link
Copy Markdown
Contributor Author

@Joerger Joerger Dec 4, 2024

Choose a reason for hiding this comment

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

would using satisfies MfaOption work here to coerce it w/out asserting?

Maybe? But I'm not sure how to import services/mfa/MfaOption since the name overlaps.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

import { MfaOption as SomeOtherMfaOption }

Comment thread web/packages/shared/utils/createMfaOptions.ts Outdated
Comment thread web/packages/teleport/src/services/mfa/mfaOptions.ts Outdated
@Joerger Joerger requested a review from ryanclark December 3, 2024 18:51
@Joerger Joerger added no-changelog Indicates that a PR does not require a changelog entry backport/branch/v17 labels Dec 3, 2024
@Joerger Joerger force-pushed the joerger/unify-mfa-types branch from a190b68 to 7ae2721 Compare December 3, 2024 18:55
@Joerger Joerger force-pushed the joerger/unify-mfa-types branch from e0ee68e to 9755a70 Compare December 3, 2024 23:31
@Joerger Joerger mentioned this pull request Dec 4, 2024
@Joerger Joerger force-pushed the joerger/unify-mfa-types branch from 2704ebc to 916e0fe Compare December 4, 2024 20:44
@rosstimothy
Copy link
Copy Markdown
Contributor

friendly ping @ryanclark @kiosion

Copy link
Copy Markdown
Member

@ryanclark ryanclark left a comment

Choose a reason for hiding this comment

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

Sorry was OOO

@Joerger Joerger added this pull request to the merge queue Dec 9, 2024
Merged via the queue into master with commit 21cdf9e Dec 9, 2024
@Joerger Joerger deleted the joerger/unify-mfa-types branch December 9, 2024 21:08
@public-teleport-github-review-bot
Copy link
Copy Markdown

@Joerger See the table below for backport results.

Branch Result
branch/v15 Failed
branch/v16 Failed
branch/v17 Create PR

carloscastrojumo pushed a commit to carloscastrojumo/teleport that referenced this pull request Feb 19, 2025
* Unify mfa types.

* Move DeviceUsage to mfa/types.

* Refactor mfa options and move to services/mfa.

* Lint fix.

* Fix mfa challenge json.

* Add MFA Option constants.

* Fix lint; Fix test.

* Address comments.

* Add license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/branch/v17 no-changelog Indicates that a PR does not require a changelog entry size/md ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants