WebAPI & IdentityServer on ASP.NET Core Project

血红的双手。 提交于 2019-12-23 15:16:44

问题


I have an ASP.NET Core project which is hosted on Azure and has many registered users. I want to create a mobile app and I need an API which provides access to same users accounts and Identity system. I found out that IdentityServer can help but I still don't understand how to use identityserver with WebAPI in the same project as I want to create a new project for webapi and allow the mobile client to authenticate using the same credentials stored in the database.

Thank you :)


回答1:


In this instance I don't believe it should be necessary to have your API (resource) and Identity Server in the same project, you can have them in separate projects.

In order to configure Identity Server 4 to work with your existing user store, I believe you need an implementation of IProfileService - brief comment at the bottom of http://docs.identityserver.io/en/release/quickstarts/3_interactive_login.html?highlight=IProfileService%20 confirms this.

Once you have your Identity Server instance hooked up to your own data store, you should then be able to protect your API with your Identity Server instance. There are a number of ways to achieve this, but I would suggest following the quick starts at http://docs.identityserver.io/en/release/quickstarts/0_overview.html will give you a good example of how to protect an API with Identity Server.



来源:https://stackoverflow.com/questions/42415026/webapi-identityserver-on-asp-net-core-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!