[英]Authentication using Angular 8 with Azure Active Directory
I am having some issues of finding forums/tutorials/examples on how to fully authenticate an angular app with Azure Active Directory.我在查找有关如何使用 Azure Active Directory 对 Angular 应用程序进行完全身份验证的论坛/教程/示例时遇到了一些问题。 So in short, I need to log in to the user via angular 8 and I am using the https://www.npmjs.com/package/@azure/msal-angular library which I found really good and easy.
简而言之,我需要通过 angular 8 登录到用户,并且我正在使用https://www.npmjs.com/package/@azure/msal-angular库,我发现它非常好且简单。 I am retrieving the token id and the user after login.
我在登录后检索令牌 ID 和用户。 The issue is, that I need to add that user to the Database because I have like a role management system which I need to add the user in the aspnet users db.
问题是,我需要将该用户添加到数据库中,因为我有一个角色管理系统,我需要将用户添加到 aspnet 用户数据库中。 I need to call an api which needs to authenticate that the user is real from .net side and then add the user to the aspnet users db.
我需要调用一个 api,它需要从 .net 端验证用户是真实的,然后将用户添加到 aspnet 用户数据库。 If he's already existing there so it just need to authenticate him and create a token.
如果他已经存在于那里,那么它只需要对他进行身份验证并创建一个令牌。 I need to know example of .net on how to populate the User.Identy with the user.
我需要知道关于如何用用户填充 User.Identy 的 .net 示例。 I am sending the api 2 headers, Authorization which is the bearer token id and access token.
我正在发送 api 2 标头,授权是不记名令牌 ID 和访问令牌。 Can someone please help?
有人可以帮忙吗?
assuming you're using aspnet core, you just need a middleware which will validate your JWT token acquired from the front end, and check if the user / token are valid (and also populate the User.Identity for you).假设您使用的是 aspnet 核心,您只需要一个中间件来验证从前端获取的 JWT 令牌,并检查用户/令牌是否有效(并为您填充 User.Identity)。
More info: https://github.com/aspnet/AspNetCore/tree/master/src/Azure/AzureAD/samples/AzureADSample更多信息: https : //github.com/aspnet/AspNetCore/tree/master/src/Azure/AzureAD/samples/AzureADSample
EDIT: for asp.net mvc (non core), you'll do the same approach: https://www.c-sharpcorner.com/article/azure-ad-authentication-for-mvc-web-application/编辑:对于 asp.net mvc(非核心),您将执行相同的方法: https : //www.c-sharpcorner.com/article/azure-ad-authentication-for-mvc-web-application/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.