简体   繁体   English

跨 ASP.Net Core Web 应用程序使用 Azure AD B2C Cookie

[英]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:推荐的方法是:

  • The web UI redirects authentication of the end user to Azure AD B2C. web UI 将最终用户的身份验证重定向到 Azure AD B2C。 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. 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.
  • The web API receives the access token in the 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.

相关问题 使用 Azure AD B2C 使用个人用户帐户登录 ASP.Net Core Web 应用程序 -> API - Sign in to ASP.Net Core Web Application -> API with Individual User Accounts using Azure AD B2C 一个使用 Azure AD B2C 的多个客户端 ID(应用程序 ID)的 ASP.NET Core 2.2 Web API 应用程序 - One ASP.NET Core 2.2 Web API app Using Multiple Client IDs (Application IDs) of Azure AD B2C 无法使用来自我的 asp.net 核心 web 应用程序的 AAD B2C 中的自定义策略登录多租户 Azure AD - unable to sign In for MultiTenant Azure AD using Custom policies in AAD B2C from my asp.net core web app 使用ASP.NET Core的Azure AD B2C - 无法编辑配置文件 - Azure AD B2C with ASP.NET Core - Unable to go to edit profile ASP.NET 浏览器关闭后核心身份验证未保持登录状态(Azure AD B2C) - ASP.NET Core Auth not staying signed in after browser closes (Azure AD B2C) ASP.NET Core 3.1 如何使用 Azure AD B2C 返回 401 Unauthorized 而不是 Challenge - ASP.NET Core 3.1 how to return 401 Unauthorized instead of Challenge with Azure AD B2C 无法使用 asp.net 核心图 API 在 Azure AD B2C 中创建自定义属性 - Can't create custom attributes in Azure AD B2C with asp.net core Graph API 跨默认域(* .azurewebsites.net)上的Azure Web应用程序的ASP.NET Core共享身份Cookie - ASP.NET Core Sharing Identity Cookie across azure web apps on default domain (*.azurewebsites.net) 如何从 Azure AD B2C 用户商店获取 ASP.NET Core 3.1 中的用户信息? - How to get user information in ASP.NET Core 3.1 from Azure AD B2C user store? ASP.NET Core 3.1 和 Azure AD B2C 与外部身份提供者身份验证 - invalid_request - ASP.NET Core 3.1 and Azure AD B2C with external Identity Providers auth - invalid_request
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM