I am working on an ASP.Net Mvc 3 application using FormsAuthentication with a custom MembershipProvider (so I do have some control over what the provider returns).
The requirements mandate a 2-step authentication process (username and password followed by secret question). A user should not be able to access any of the “secure” sections of the site without passing both steps. Please don’t mention whether this is multi-factor security or not, I already know.
Please provide a recommendation on how to best accomplish this task.
Here are some considerations:
- I am allowed (architecturally) to use session – would prefer not to.
- I would prefer to use the out-of the box
[Authorize]ActionFilterfor Controllers providing secure content. - The people in charge would like for the url for the 2 steps to be the same: i.e.
www.contoso.com/login/. In my attempts at least, this has caused some minor-but-not-insignificant issues when users enter an incorrect answer in the second step (they are not officially logged in, but I need to ensure that I am still working against the half-authenticated user’s secret question/answer).
Thanks.
Use a custom View Model in conjunction with hidden form fields. Just make sure it’s all done over https.
ViewModel
Action Methods
View
If you’re not happy with sending the username and password back to the view in hidden fields to re-authenticate and make sure they’re not cheating… you could create a HMAC or something like that to test.
Btw, this question seems like a few questions rolled into one… so just answered how to do 2-step authentication with one view / action method.