2

I have a Web Api that returns basic info about a company's info. The login information is validated with their DB (this is used for an Desktop App) but with AngularJS im only ask to the API for Username and Password. How i can implement an authentication system (like the default on Visual Studio) on this with their users and passwords? Is possible to use something like Token? Can you help me? Thanks a lot.

[EDIT 1]

By the way, this webapi uses an old foxpro DB to manage the users and password. So if i gone to use the authentication system, i don't know how to use de database context with this type of old DB.

Ali Briceño
  • 1,096
  • 2
  • 17
  • 44

2 Answers2

1

You can look at this step by step article.

rnofenko
  • 9,198
  • 2
  • 46
  • 56
  • i am reading the document right now, but i see that the author uses Entity F. for the user management (also he declares the class `class AuthContext : IdentityDbContext`) but i have a old Foxpro DB that already have the users and password. How can i do on this case?? – Ali Briceño Jan 30 '16 at 03:30
  • I already do. Just i coded my own OAuthAuthorizationServerProvider and now works with the Bearer and my custom UserName and Password with FoxPro DB without any problems. – Ali Briceño Jan 30 '16 at 05:24
0

Your question is quite broad, but let's try to tackle it. Basically, you need to split it into two:

  1. Communication with FoxproDb from within ASP.NET. There are lots of Q&A here on Stackoverflow on that, for example: FoxPro Database and asp.net.

    Consider migrating from FoxproDb to Sql Server if possible.

  2. Authentication is also big topic, but Basic Authentication is an option if you are building Intranet app or app that will be secured with HTTPS. I have looked through tons of articles, and this one is probably the EASIEST and most ot the point Web Api2 Basic Authentication - and if you are going with AngularJs frontend, you'll probably want WebApi2 as backend.

    Now, be aware that with Basic Authentication you are sending credentials with every request and thus it's easy to steal username:passwords. If you want to support HTTP you'll probably need to go with some other authentication system.

Other good links:

User Authentication in ASP.NET Web API

Community
  • 1
  • 1
nikib3ro
  • 20,366
  • 24
  • 120
  • 181
  • Thanks pal for the info. I already solutioned this with the help of the article [link](http://bitoftech.net/2014/06/01/token-based-authentication-asp-net-web-api-2-owin-asp-net-identity/). Sorry but i cannot tells to the customer that has to migrate the DB because he can't do this. Thanks anyway! – Ali Briceño Jan 30 '16 at 05:26