-
Notifications
You must be signed in to change notification settings - Fork 9
fix(auth): resolve MFA option by label, type, or display string #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -450,6 +450,37 @@ func (c AuthConnectionCmd) Submit(ctx context.Context, in AuthConnectionSubmitIn | |
| return fmt.Errorf("must provide at least one of: --field, --mfa-option-id, or --sso-button-selector") | ||
| } | ||
|
|
||
| // Resolve MFA option: the user may pass the label (e.g. "Get a text"), the | ||
| // type (e.g. "sms"), or the display string ("Get a text (sms)"). The API | ||
| // expects the type, so look up the connection's available options and map | ||
| // whatever the user provided to the correct type value. | ||
| if hasMfaOption { | ||
| conn, err := c.svc.Get(ctx, in.ID) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to fetch connection for MFA option resolution: %w", err) | ||
| } | ||
| if len(conn.MfaOptions) > 0 { | ||
| resolved := false | ||
| for _, opt := range conn.MfaOptions { | ||
| displayName := fmt.Sprintf("%s (%s)", opt.Label, opt.Type) | ||
| if strings.EqualFold(in.MfaOptionID, opt.Type) || | ||
| strings.EqualFold(in.MfaOptionID, opt.Label) || | ||
| strings.EqualFold(in.MfaOptionID, displayName) { | ||
| in.MfaOptionID = opt.Type | ||
| resolved = true | ||
| break | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Label match can shadow exact type match on later optionLow Severity The resolution loop checks type, label, and display string for each option before moving to the next. A label match on an earlier MFA option can shadow an exact type match on a later option, resolving to the wrong type. For correct priority, type matches across all options need to be checked before falling back to label matches.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a real concern in practice. MFA types come from a fixed set ( |
||
| } | ||
| if !resolved { | ||
| available := make([]string, 0, len(conn.MfaOptions)) | ||
| for _, opt := range conn.MfaOptions { | ||
| available = append(available, fmt.Sprintf("%s (%s)", opt.Label, opt.Type)) | ||
| } | ||
| return fmt.Errorf("unknown MFA option %q; available: %s", in.MfaOptionID, strings.Join(available, ", ")) | ||
| } | ||
| } | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| } | ||
|
|
||
| params := kernel.AuthConnectionSubmitParams{ | ||
| SubmitFieldsRequest: kernel.SubmitFieldsRequestParam{ | ||
| Fields: in.FieldValues, | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.