Skip to content

Add form validation for present TOTP name#6267

Merged
aduth merged 6 commits intomainfrom
aduth-validate-totp-name
Apr 28, 2022
Merged

Add form validation for present TOTP name#6267
aduth merged 6 commits intomainfrom
aduth-validate-totp-name

Conversation

@aduth
Copy link
Contributor

@aduth aduth commented Apr 28, 2022

Extracted from #6229

Why: For consistency with other MFA setup, and for consistency with the JS-enabled user experience, where the input is rendered as required.

This was discovered in #6229, where the set_up_2fa_with_authenticator_app spec helper would not work as expected in a JavaScript-enabled browser, since the browser validation would prevent submission without a valid name.

The previous implementation seemed to be intentionally allowing an absent name. While this may be reasonable if applied consistently, the revisions bring alignment to client-side and server-side validation, and across different MFA types (e.g. PIV/CAC).

aduth added 4 commits April 28, 2022 08:45
**Why**: For consistency with other MFA setup, and for consistency with the JS-enabled user experience, where the input is rendered as required.

changelog: Bug Fixes, MFA Setup, Consistently validate TOTP name
@jmhooper
Copy link
Contributor

The previous implementation seemed to be intentionally allowing an absent name.

Do we know what the previous version was allowing a blank name? Any thoughts on adding making the name required by the validator? Additionally, do we have auth app configs without a name?

@mitchellhenke
Copy link
Contributor

mitchellhenke commented Apr 28, 2022

Do we know what the previous version was allowing a blank name? Any thoughts on adding making the name required by the validator? Additionally, do we have auth app configs without a name?

Yeah, my worry is that since we update the totp_timestamp on use, it would fail to update since the validation fails on the name?

@jmhooper
Copy link
Contributor

jmhooper commented Apr 28, 2022

Yeah, but we could backfill them with something generic like "Authentication app 1" and then add the validation

@jmhooper
Copy link
Contributor

Oh wait, I totally got the red and green in this diff backwards! Since this is the setup form and the validation is not on the model it shouldn't create a problem for configurations when we update them. We should probably still backfill though so we aren't surprised to encounter a blank name

@aduth
Copy link
Contributor Author

aduth commented Apr 28, 2022

Yeah this is mostly a UI consistency problem. The records themselves always have and will continue to have names associated with them, but previously we weren't requiring this to be provided by the form, and instead would default to the current date when not provided by the form.

In practice, I expect this would rarely have happened in the wild, since the field is "required" and enforced by browser validation. The fact that we weren't validating previously seemed to be more for the convenience of our own specs, which typically don't (or at least didn't, prior to #6229) run with JavaScript enabled.

image

aduth added 2 commits April 28, 2022 10:40
should be unique user / MFA setup between specs
@aduth aduth merged commit 0c60add into main Apr 28, 2022
@aduth aduth deleted the aduth-validate-totp-name branch April 28, 2022 15:21
peggles2 pushed a commit that referenced this pull request May 3, 2022
* Add form validation for present TOTP name

**Why**: For consistency with other MFA setup, and for consistency with the JS-enabled user experience, where the input is rendered as required.

changelog: Bug Fixes, MFA Setup, Consistently validate TOTP name

* Pass name parameter for controller specs

* Improve specs for TOTP setup controller

* Fill in name

* More forms!

* Try non-unique app names in specs

should be unique user / MFA setup between specs
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.

3 participants