azure - 使用服务器端 Blazor 进行 Multi-Tenancy Azure 应用程序注册

标签 azure active-directory azure-active-directory blazor blazor-server-side

我在 Visual Studio 2022 中使用默认 Blazor 服务器模板,并将身份验证设置为使用 Microsoft Identity Platform。

我的 Azure Active Directory 帐户中有一个 AppRegistration,设置为允许任何组织中的帐户( Multi-Tenancy ):

enter image description here

在我的 appsettings.json 文件中,我使用正确的客户端和租户 ID:

enter image description here

当我运行应用程序时,我可以使用我的 AAD 租户(或已受邀加入我的 AAD)中的任何帐户登录。但是,当我尝试使用另一个 AAD 租户的身份时,出现以下错误:

Selected user account does not exist in tenant 'TENANT NAME' and cannot access the application 'APP-REGISTRATION-ID' in that tenant. The account needs to be added as an external user in the tenant first. Please use a different account.

根据我在文档和其他文章中找到的内容,我需要使用通用端点进行登录,但是如果我将应用程序设置中的“域”更改为“通用“ 如果我将 “实例” 更新为 https://login.microsoftonline.com/common/oauth2/authorize ,这不会产生任何影响。 https://login.microsoftonline.com/common/ 由于 URL 不正确,我收到异常。

也许默认 Blazor 服务器模板设置为使用单租户应用注册?我怎样才能让它正确使用 Multi-Tenancy ?

最佳答案

根据所选支持的帐户类型,您必须更改 TenantId 中的>appsettings.json 文件。

  • 对于单租户帐户类型,应为“your_tenant_id

  • 对于 Multi-Tenancy 帐户类型,应为“组织

  • 对于 Multi-Tenancy 和个人 Microsoft 帐户类型,应为“通用

由于您已选择“任何组织目录中的帐户(任何 Azure AD 目录 - Multi-Tenancy )”,请通过更改您的 appsettings.json 值进行检查,如下所示:

您的 TenantId 值必须为 organizations,并且您的 ClientId 值必须为your_application_id

enter image description here

请检查您的域名值。您可以在Azure AD 概述页面中找到您的:

enter image description here

确保在 重定向 URI 中包含 appsettings.json 文件中的 CallbackPath 您的应用程序以避免重定向 URI 不匹配错误。

如果有帮助,请查找以下引用资料。

引用文献: Ref1 , Ref2 , Ref3

关于azure - 使用服务器端 Blazor 进行 Multi-Tenancy Azure 应用程序注册,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71541033/

相关文章:

asp.net - 如何使用 CICD 管道将带有 Linux 应用程序服务计划的 ASP .NET Core 应用程序部署到 azure?

r - azuremlsdk 存储 azure 凭据的最佳实践

powershell - 仅在使用 ISE 时才会出现确认对话框

使用 OAuth2.0 和 AAD 进行 Azure API 管理?

azure - 如何在 ARM 模板中打开 Azure SQL 数据库的审核和威胁检测?

python - 如何从Python中的x509证书中提取公钥?

powershell - 根据列表禁用的AD用户

active-directory - Ldap 查询仅返回 1000 个用户...是的,我正在使用分页

azure - 在哪里可以找到域名以在应用程序中使用 Azure AD 身份验证

azure - 如何让 Azure OIDC 尊重我的重定向 URI?