简体   繁体   中英

Web Api ASP.NET Custom Authentication

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.

您可以逐步阅读此文章

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM