简体   繁体   English

使用 Azure AD 进行 Dotnet 核心身份验证

[英]Dotnet core Identity authentication with Azure AD

I got a question using the azure AD authentication.我遇到了一个使用 azure AD 身份验证的问题。 Out team started to develop an Identity application to handle the authentication request of all our application services. Out 团队开始开发一个 Identity 应用程序来处理我们所有应用程序服务的身份验证请求。

For logging in users we have to use Azure AD beacause we dont want our users to create a new accunt but rather use their company microsoft account to login into our applications.对于登录用户,我们必须使用 Azure AD 因为我们不希望我们的用户创建新帐户,而是使用他们公司的 Microsoft 帐户登录我们的应用程序。

The problem is tha when the user enters the application.问题是当用户进入应用程序时。 It gets the azure access token as described in the microsoft azure documentation, but we would like to create our own custom token for this authenticated person which contains extra information from our database.它获取 azure 访问令牌,如 microsoft azure 文档中所述,但我们想为这个经过身份验证的人创建我们自己的自定义令牌,其中包含来自我们数据库的额外信息。

We tried to implement identityserver with external providers as described in the documentation ,but not so much success.我们尝试使用文档中描述的外部提供者来实现身份服务器,但没有那么成功。

So the problem for us is the conversion from azure identity to our own custom identity.所以我们的问题是从 azure 身份到我们自己的自定义身份的转换。

Any idea/suggestion how to implement such a server/client?任何想法/建议如何实现这样的服务器/客户端?

You can use identity server 4 as identity provider and add Azure AD as external login, here is code sample, you can add Azure AD login like:您可以使用身份服务器 4 作为身份提供者并添加 Azure AD 作为外部登录, 这里是代码示例,您可以添加 Azure AD 登录,如:

services.AddAuthentication()
.AddOpenIdConnect("aad", "Azure AD", options =>
{
    options.ClientId = "<app>";
    options.Authority = "https://login.microsoftonline.com/<tenant>/";             
    options.CallbackPath = "/signin-oidc-aadtenant";            
    options.SaveTokens = true;                                 
    options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;

})

You might show the detail issue when implement the whole process.在实施整个过程时,您可能会显示细节问题。

You can possibly make use of custom policy in Azure AD B2C.您可以在 Azure AD B2C 中使用自定义策略。 Read here https://docs.microsoft.com/en-us/azure/active-directory-b2c/custom-policy-get-started在这里阅读https://docs.microsoft.com/en-us/azure/active-directory-b2c/custom-policy-get-started

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

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