0

I need to build a RESTfull web service using OAuth, bearer access_token and refresh_token. Authentication and authorization should be done by checking existing sql db.

The web api template, provided by VS2013 writes/reads in/from its own local sqlexpress db by this connectionString:

connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-WebApiTest-20150423094253.mdf;Initial Catalog=aspnet-WebApiTest-20150423094253;Integrated Security=True"

After hours of googling, I just got tutorials and examples, which do not match with my issue.

So how can I bind my db into the project for authentication/athorization?

General Grievance
  • 4,555
  • 31
  • 31
  • 45
L C
  • 438
  • 2
  • 10
  • 28
  • Did you ever find an answer to this issue? – crthompson Jun 11 '15 at 18:04
  • No. Do you know the answer? – L C Jun 12 '15 at 10:33
  • I"m in the middle of doing it now. Its a bit of a complicated answer and I dont have it complete yet, but I've received help from [these](http://stackoverflow.com/a/28526641/2589202) [answers](http://bitoftech.net/2014/06/01/token-based-authentication-asp-net-web-api-2-owin-asp-net-identity/). Once I get through it I'll try to create an answer that is not too long. – crthompson Jun 12 '15 at 15:02
  • I've found [this post](http://codebetter.com/johnvpetersen/2012/04/02/making-your-asp-net-web-apis-secure/) and it is exactly what I want. I think it is what you're describing here also. The key is in his `TokenValidationAttribute` there is a line `AuthorizedUserRepository.GetUsers...` this just needs to be replaced with a query to your database. Seems to be much simpler than the OWIN stuff. – crthompson Jun 12 '15 at 18:41

0 Answers0