简体   繁体   English

如何在ASP.NET Identity 2.0中验证承载令牌?

[英]How to Validate a bearer token in ASP.NET Identity 2.0?

I have a ASP.NET WEB API(project 1) that uses Asp.Net Identity 2.0 to authenticate users. 我有一个ASP.NET WEB API(项目1),它使用Asp.Net Identity 2.0对用户进行身份验证。 This API is just for authentication and authorisation purpose. 该API仅用于身份验证和授权目的。

I have two more projects 我还有两个项目

  1. ASP.NET MVC 5 project(project 2) ASP.NET MVC 5项目(项目2)
  2. ASP.NET WEB API (project 3) - this includes services related to business. ASP.NET WEB API(项目3)-包括与业务相关的服务。

all the three projects use https. 这三个项目都使用https。

MVC project collects username, password and sends it to the API project(project 1). MVC项目收集用户名和密码,并将其发送到API项目(项目1)。 Api Project(project 1) authenticates the user and sends back a bearer token. Api Project(项目1)对用户进行身份验证并发回承载令牌。 An authentication cookie is set in the mvc project(project 2). 在mvc项目(项目2)中设置了身份验证cookie。 It works well upto this. 到目前为止效果很好。

Now I want to pass the bearer token from MVC project(project 2) to the Second API(project 3) and get it(project 3) authenticated. 现在,我想将承载令牌从MVC项目(项目2)传递到第二个API(项目3),并进行身份验证(项目3)。 I can't find a method in UserManager to Validate a bearer token. 我在UserManager中找不到验证承载令牌的方法。

Any Ideas? 有任何想法吗?

您是否尝试过在正在调用的api函数上使用[Authorize]属性?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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