ASP Net Core - Mixing External Identity Provider with Individual User Accounts for Audit Tracking

隐身守侯 提交于 2019-12-07 13:40:11

问题


I have created a default ASP Net Core MVC web app with Individual User Accounts. I added a custom UserID INT field to the AspNetUsers table and linked this as a foreign key to all my other custom tables so I can track what users inserted/updated records in my database. I did this as I prefer using INT fields for primary keys. In this scenario everything is working fine.

I am now thinking of using an external identity provider such as Azure Active Directory however I cannot work out how I would link a user in Azure AD (or any other identity provider) to my local database tables to maintain the user id foreign key constraints. From all my research I cannot find any articles for this scenario.

How can I link user info from an external identity provider to my local database tables? I am worried that I might need to double handle the user account management in both the external identity provider and my local AspNet user tables to maintain the foreign keys with my other custom tables which seems crazy.

Perhaps i'm missing something obvious or my approach is all wrong so if there is a better alternative for tracking who did what in my database tables for an ASP Net Core web application using an external identity provider I would happily adopt it.


回答1:


There is no need to additional steps to link the user info for the user from external identity provider. It should looks be same for the web app.

When the users login from external identity provider, it still require to register the users to bind the user with individual accounts. The only difference is that there is no password for this kind of individual account and it can match the record in the AspNetUserLogins. Here are two accounts, one is binding to the external identity provider and the other is not:



来源:https://stackoverflow.com/questions/45186025/asp-net-core-mixing-external-identity-provider-with-individual-user-accounts-f

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