简体   繁体   English

来自另一个Web API应用程序的身份验证和授权ASP.NET Web API

[英]Authentication and authorization ASP.NET Web API from another Web API Application

Hi everyone I have an issue, I have one Asp.NET Web.API application with User management functionality from example Create User manage User Permissions ect, and now I have developed another Web.API application and I need to implement authentication and authorization via first application users credentials. 大家好,我有一个问题,我有一个具有“用户管理”功能的Asp.NET Web.API应用程序,例如“创建用户管理用户权限”等示例,现在我开发了另一个Web.API应用程序,我需要首先实现身份验证和授权应用程序用户凭据。 What is the best approach or solution to achieve this goal? 实现此目标的最佳方法或解决方案是什么? Note that in first app I changed the classic Role base Authorization into Permission based. 请注意,在第一个应用程序中,我将经典的“角色库授权”更改为“基于权限”。

Thanks in advance for any help. 在此先感谢您的帮助。

I have developed another Web.API application and I need to implement authentication and authorization via first application users credentials. 我已经开发了另一个Web.API应用程序,并且需要通过第一个应用程序用户凭据来实现身份验证和授权。

There are a lot of ways to implement the solution. 有很多方法可以实现该解决方案。 One way is use to token-based authentication using Identity Server . 一种方法是使用Identity Server 进行基于令牌的身份验证

You could test my sample code at GitHub . 您可以在GitHub上测试我的示例代码

Please note that it uses InMemory Identity Database with hard-coded username and password for testing. 请注意,它使用带有硬编码用户名和密码的 InMemory Identity Database进行测试。 You could replace with real Identity Database easily. 您可以轻松地用真实的身份数据库替换。

I had a similar issue so I moved all of my authentication and authorization into an IHTTP Module. 我遇到了类似的问题,因此我将所有身份验证和授权都移到了IHTTP模块中。 This allowed me to set the applications module in IIS 7.0. 这使我可以在IIS 7.0中设置应用程序模块。 https://msdn.microsoft.com/en-us/library/ms227673.aspx https://msdn.microsoft.com/zh-CN/library/ms227673.aspx

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

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