Skip to content

feat: pin MFA factor via preferred_mfa_factor_id - #503

Merged
epierce merged 3 commits into
Nike-Inc:masterfrom
jorgeclaro:feat/pin-mfa-factor-id
May 20, 2026
Merged

feat: pin MFA factor via preferred_mfa_factor_id#503
epierce merged 3 commits into
Nike-Inc:masterfrom
jorgeclaro:feat/pin-mfa-factor-id

Conversation

@jorgeclaro

Copy link
Copy Markdown
Contributor

Description

Adds optional preferred_mfa_factor_id config key that pins a specific MFA factor by Okta's stable factor id. Applied after preferred_mfa_type / preferred_mfa_provider in 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_type narrows 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?

  • New unit tests in tests/test_okta_classic_client.py covering: pin-hit auto-select, pin-miss fall-through to picker, pin overrides preferred_mfa_type when both are set.
  • Full suite passes (95/95).
  • Manual smoke against a personal Okta tenant with multiple webauthn authenticators enrolled: picker prints the factor id; pinning a specific id skips the sub-picker on subsequent runs.

Screenshots (if appropriate):

N/A — CLI behavior change.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

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.

@epierce epierce left a comment

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.

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

Comment thread gimme_aws_creds/okta_classic.py Outdated
@jorgeclaro
jorgeclaro requested a review from epierce May 18, 2026 15:30
@epierce
epierce merged commit 20246ed into Nike-Inc:master May 20, 2026
8 checks passed
@jorgeclaro
jorgeclaro deleted the feat/pin-mfa-factor-id branch May 21, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support to set TouchID / Windows Hello authentication as preferred_webauthn on config file

2 participants