Authentication flow for Angular application for users in Azure AD

人盡茶涼 提交于 2020-01-22 02:27:46

问题


I have an Angular application which talks to several WEB API's to provide an interacted UI. I am finding really hard time in finding a way to. I am following this article which explains the Angular part of it. I am able to get the token at client side. How can my dot net core web API validate the token if the client sends this id token?


回答1:


You can use JwtBearer middleware which enables an application to receive an OpenID Connect bearer token. In this document it provides code sample .

Or you can use AzureADAuthenticationBuilderExtensions.AddAzureADBearer Method in Microsoft.AspNetCore.Authentication.AzureAD.UI library :

services.AddAuthentication(AzureADDefaults.BearerAuthenticationScheme)
            .AddAzureADBearer(options => Configuration.Bind("AzureAd", options));

And bind the config in appsettings.json:

"AzureAd": {
    "Instance": "https://login.microsoftonline.com/",
    "Domain": "xxxxx.onmicrosoft.com",
    "TenantId": "cb1c3f2e-a2dd-xxxx-bf8f-f75ab18b21ac",
    "ClientId": "511ece54-a7a2-xxxx-a9f9-bd224e1d0a0f"
},


来源:https://stackoverflow.com/questions/57604230/authentication-flow-for-angular-application-for-users-in-azure-ad

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