[英]Use Azure AD B2C Cookie across ASP.Net Core Web Apps
I have two ASP.Net Core 3 Web App projects.我有两个 ASP.Net Core 3 Web App 项目。 Both use Azure AD B2C to authenticate.两者都使用 Azure AD B2C 进行身份验证。 One is technically an API but I have included the Cookie authentication service so that the browser can easily be used to make API requests.一个在技术上是 API 但我已经包含了 Cookie 身份验证服务,以便可以轻松地使用浏览器来发出 API 请求。
This seems to work although each app likes to request its own cookie which overrides the other's.尽管每个应用程序都喜欢请求自己的 cookie 来覆盖其他应用程序,但这似乎可行。 I could avoid them from overriding each others, but I'd prefer that once authenticated via the UI, the API can use the same cookie/bearer token.我可以避免它们相互覆盖,但我希望通过 UI 进行身份验证后,API 可以使用相同的 cookie/承载令牌。 I can't find anything online but I am new to ASP.Net development to know if I'm searching for the right thing.我在网上找不到任何东西,但我是 ASP.Net 开发的新手,知道我是否在寻找正确的东西。
What's the best/correct approach for this?对此最好/正确的方法是什么?
Thanks!谢谢! Tom汤姆
The recommended approach is:推荐的方法是:
Authorization
header to the web API. If authenticated, then it acquires an access token from Azure AD B2C and sends this access token in the Authorization
header to the web API.Authorization
header from the web app and validates it. web API 从 Z2567A5EC9705EB7AC2C98403 的Authorization
header 中接收访问令牌并验证 E.E. If valid, then it allows the API call;如果有效,则允许 API 调用; otherwise, it denies it.否则,它会否认它。An example of this can be found in the Azure AD B2C: Call an ASP.NET Web API from an ASP.NET Web App sample . An example of this can be found in the Azure AD B2C: Call an ASP.NET Web API from an ASP.NET Web App sample .
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.