向WebApi添加基本身份验证

时间:2019-02-16 16:34:05

标签: asp.net-web-api2

我想向我的web-api项目添加基本身份验证。 我有与用户一起使用的表(整数ID,字符串名称,…还有其他字段) 我想添加身份验证,如下所示:

-firsttly i create new table UserId / Password
-when the user logs in he get some hashKey
-every controller beside authController check if the authtenticationKey exists in http request header (authorization)

如果存在,则控制器需要具有来自authtenticationKey的登录用户ID

该怎么做?

我知道如何创建表格以及服务,该服务将检查用户/密码对, 但我不知道如何创建控制器,在正确登录后将返回(或添加到标题)“ authtencitacionKey” 然后每个控制器都将通过具有“ Authorize”属性来使用此键

0 个答案:

没有答案