feat: pin MFA factor via preferred_mfa_factor_id - #503
Merged
Conversation
preferred_mfa_type narrows to a factor type but leaves the sub-picker visible when multiple factors share that type (e.g. several webauthn authenticators enrolled at Okta). Add a new config key preferred_mfa_factor_id that pins one factor by its Okta id, applied after the existing type/provider filters and overriding them when matched. On miss, lists the available ids and falls through to the interactive picker. Factor ids are now also printed alongside each choice in the picker so users can discover the id to pin.
jorgeclaro
marked this pull request as ready for review
May 18, 2026 12:06
epierce
requested changes
May 18, 2026
epierce
left a comment
Member
There was a problem hiding this comment.
Looks good other than the warning if the factor id isn't found - listing the available factor ids makes that message almost unreadable if you have a lot of factors enrolled
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds optional
preferred_mfa_factor_idconfig key that pins a specific MFA factor by Okta's stable factor id. Applied afterpreferred_mfa_type/preferred_mfa_providerin the existing filter chain in_choose_factor; on miss, falls through to the interactive picker (same notify-and-fall-through pattern the existing two filters use). The picker output now prints the factor id alongside the display name so the id is discoverable in-place.Classic only — Okta Identity Engine delegates MFA to the browser device-code flow and has no analogous picker.
Related Issue
Fixes #491.
Motivation and Context
preferred_mfa_typenarrows by factor type (webauthn,push,token:software:totp, etc.) but can't pin a specific instance within a type. With multiple webauthn authenticators enrolled at Okta (Touch ID, iCloud Keychain, password managers, hardware keys), the sub-picker still appears on every run. Existing workarounds — typing the index each time, or deregistering unused authenticators at Okta (affects all Okta logins, not just AWS) — are both poor.Compared to the OP's name-based
preferred_webauthn, an id-based key works across all factor types and avoids fragile name matching when two devices share a label.How Has This Been Tested?
tests/test_okta_classic_client.pycovering: pin-hit auto-select, pin-miss fall-through to picker, pin overridespreferred_mfa_typewhen both are set.Screenshots (if appropriate):
N/A — CLI behavior change.
Types of changes
Checklist: