10
votes

We are planning to start developing our new site with ASP.Net, MVC and AngularJS. I will also have a WebApi that i would like to use oAuth authentication with, because it is easy to to pass in token, plus may want to allow users to login with Google, Facebook etc in the future.

Questions

  1. If i want to use oAuth on my WebApi (which is a separate application), what authentication method should i be using for my asp.net MVC website? oAuth? Forms? Both? And how do you implement this? On my API i wrote a simple oAuth provider that asks for a username and password and returns a token string.

  2. Should my WebApi have a single sign on login page to interact with the website? Or should the login page be on the website? Should the login page use client side calls or server side calls?

  3. What is actually within the oAuth token and how does it link to my website? Do I have to do something on the server once they login via Facebook/Google? Can I use this token on my server to determine which user is logged in?

  4. Our website has many databases, all the same, but depending which user is logging in, depends on which database they can view data from. Is this easy to cope with using standard method/objects in ASP.Net MVC? Or is this going to force me in writing my own code?

Any advice would be appreciated as well!

2
I'm not sure this helps but I used oAuth with MVC and azure mobile services for Silicon Valley Code Camp and it went pretty well.slideshare.net/peterkellner99/oauth-36039477 meetup.com/BayNET/events/185540132 - Peter Kellner
this should help a lot bitoftech.net/2014/07/16/… - Bilal

2 Answers

1
votes

If are you planning to use MVC 5 You could use Asp.Net Identity. Take a look here: http://www.asp.net/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on

I hope this could help you. Diego

1
votes

Your best bet :

This topic shows how to secure a web API using OAuth2 to authenticate against a membership database for both local and social login

http://www.asp.net/web-api/overview/security/individual-accounts-in-web-api