简体   繁体   English

使用 Angular 8 和 Azure Active Directory 进行身份验证

[英]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.

相关问题 使用 Azure Active Directory 的 Azure Function 身份验证 - Azure Function authentication using Azure Active Directory Asp.net Identity使用密码和Azure Active Directory身份验证 - Asp.net Identity using password and Azure Active Directory authentication 使用Active Directory的Silverlight身份验证 - Silverlight authentication using Active Directory ASP.NET中的Azure Active Directory身份验证 - Azure active directory authentication in asp.net 如何挑战Windows Azure Active Directory身份验证? - How to challenge Windows Azure Active Directory authentication? Azure Active Directory和Avocado API身份验证 - Azure Active Directory and avocado api authentication Azure 使用 .net 核心 3.1 中的 azure 活动目录(单租户)的广告身份验证和授权? - Azure Ad authentication and authorization using azure active directory (single tenant) in .net core 3.1? 将 Azure Active Directory 与 Azure 密钥库一起使用 - Using Azure Active Directory with Azure Key Vault 无法使用 Authentication=Active Directory Managed Identity 从 do.net web 应用程序连接到 Azure SQL MI - Unable to connect to Azure SQL MI from dotnet web application using Authentication=Active Directory Managed Identity 使用身份框架进行用户身份验证的 Azure Active Directory 身份验证和现有应用程序。 使用 ADAL 或 Web Api - Azure Active Directory Authentication with and Existing App which is using Identity framework for user authentication. Using ADAL or Web Api
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM