ASP.NET Web API with custom authentication

前端 未结 3 1129
野的像风
野的像风 2021-02-13 20:55

I am looking for help creating a Web API with custom username/password authentication.

I have my own database to validate users against, I do not want to use windows aut

3条回答
  •  醉梦人生
    2021-02-13 21:47

    Depending on which version you are using. MVC5 Web API 2 implements an approach called bearer tokens. So you basically execute a post with username and password upfront to your https://applicationhostlocation/token endpoint. This will return a bearer token in the payload. You send subsequent https requests to your authorized web api methods with the bearer token in a header. This is all out of the box with the latest version of the web api. This link outlines the approach pretty well: http://www.asp.net/web-api/overview/security/individual-accounts-in-web-api

提交回复
热议问题