My application uses two factor authentication with username/password followed by a code sent to the user by SMS or e-mail. I've been using cookies to remember users, but now I want to use bearer tokens in OAuth instead, with the help of OWIN.
Does OAuth solve two factor authentication somehow? If not, would it be a bad idea to:
- Client sends (post) user credentials to
/api/authentication
(an ApiController)- If credentials are wrong, server responds with
400 Bad Request
- If credentials are correct, server generates a code and sends it to the user by SMS. Then it responds with
401 Unauthorize
withWWW-Authenticate: ???
to the client
- If credentials are wrong, server responds with
- Client sends code to
/token
(OAuth) withgrant_type=password&username={code}