mmacneil / AngularASPNETCore2WebApiAuth

Sample project demonstrating jwt-based authentication with an Angular (v5.2.1) frontend and ASP.NET Core 2 WebApi. Includes both local user registration with .NET Core Identity membership and facebook login scenarios.
https://fullstackmark.com/post/13/jwt-authentication-with-aspnet-core-2-web-api-angular-5-net-core-identity-and-facebook-login
MIT License
473 stars 238 forks source link

Two factor authentication? #5

Closed kjartanvalur closed 6 years ago

kjartanvalur commented 6 years ago

Hi Thanks for this awesome code sample. Do you think it´s possible to add two factor authentication via SMS or Email?

mmacneil commented 6 years ago

Hi @kjartanvalur - thanks for the feedback. Re: two factor authentication this demo could be extending very easily to include that. In fact, you can get the code to plug in by creating a new asp.net mvc web application, include authentication -> "Individual User Accounts" that project template creates a very rich AccountsController for you with 2fa, password reset etc... I just pasted into this gist: https://gist.github.com/mmacneil/e7e234569802e74e93500bf2abee98dc#file-cs

That should have everything you need to implement 2fa in your demo project.

Regards, Mark

kjartanvalur commented 6 years ago

Hi Thanks for this info. I had already noticed this template but I´m not interested using Razor pages or MVC. I´m trying to do this with pure REST and Angular.

Any thoughts on that?

mmacneil commented 6 years ago

Yes, so you don't need to use razor/mvc - that example shows you most of the logic/workflow which you should be able to port (relatively) easily into your restful api to do 2fa. You should be able to ignore the mvc bits (ie. don't review View()) - see the LoginWith2fa() actions.

Hope this helps. Mark