且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

来自不受管理的Azure AD目录的用户可以登录到位于其他目录中的Azure AD多租户应用程序吗?

更新时间:2023-02-20 19:51:32

有关编写Azure AD多租户应用程序的最流行的指南和示例建议使用公共终结点而不是特定于租户的终结点.

The most prevalent guidance and examples for writing Azure AD multi-tenant apps recommend using the common endpoint instead of tenant specific endpoint.

Common endpoint: https://login.microsoftonline.com/common/oauth2/authorize
Tenant specific endpoint: https://login.microsoftonline.com/company.com/oauth2/authorize

公共端点允许任何租户的用户登录.它通过进行租户发现来实现此目的,这意味着,它将根据用户的电子邮件自动将用户重定向到其租户端点.但是,这也意味着user@company.com将始终以company.com的员工身份登录,而永远不会作为其他公司的访客通过B2B协作功能被添加为访客. ,公共端点不支持访客.

The common endpoint allows users from any tenant to log in. It achieves this by doing tenant discovery, meaning that, based on the user's email, it'll automatically redirect the user to their tenant endpoint. However, this also means that user@company.com will always be signed-in as an employee of company.com and never as a guest of some other company they've been added as a guest to via the B2B collaboration feature - In short, the common endpoint doesn't support guests.

另一方面,特定于租户的端点仅允许该租户中的用户登录.虽然它不执行租户发现,但仍允许其他租户中的用户尝试登录,但随后将进行检查以查看(如果已将它们添加为租户的来宾).否则,登录将失败-简而言之,来宾用户(通过B2B协作功能添加的用户)只能在特定于租户的端点中工作.

The tenant specific endpoint on the other hand, only allows users from that tenant to log in. While it doesn't do tenant discovery, it still allows users from other tenants to attempt to sign in, but will then check to see if they've been added as guests to the tenant. If they haven't, the sign in will fail - In short, guests users (users added via the B2B collaboration feature), only work in the tenant specific endpoint.

如果您希望多租户应用程序支持来宾,则需要自己进行租户发现并利用租户特定的端点而不是公共端点.

这意味着您的应用程序将需要知道哪个Azure AD租户与每个工作区/团队/实例/所有隔离级别相关联,例如:

This means that your application will need to know which Azure AD tenant is associated to each workspace/team/instance/whatever-isolation-level-in-the-all, for example:

contoso.myapp.com or www.myapp.com/contoso will sign in users via login.microsoftonline.com/contoso.com

fabrikam.myapp.com or www.myapp.com/fabrikamwill sign in users via login.microsoftonline.com/fabrikam.com