在 Identity Platform 中设置多租户

本快速入门介绍如何为 Identity Platform 启用多租户,以及如何使用 Google Cloud 控制台创建和选择新租户。

如需详细了解 Identity Platform 中的多租户,请参阅多租户


如需在 Google Cloud 控制台中直接遵循有关此任务的分步指导,请点击操作演示

操作演示


准备工作

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. 如果您要使用现有项目来完成本指南,请验证您是否拥有完成本指南所需的权限。如果您创建了新项目,则您已拥有所需的权限。

  4. Verify that billing is enabled for your Google Cloud project.

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  6. 如果您要使用现有项目来完成本指南,请验证您是否拥有完成本指南所需的权限。如果您创建了新项目,则您已拥有所需的权限。

  7. Verify that billing is enabled for your Google Cloud project.

  8. 所需的角色

    如需获得设置多租户所需的权限,请让您的管理员为您授予项目的 Identity Platform Admin (roles/identityplatform.admin) IAM 角色。如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限

    此预定义角色包含设置多租户所需的权限。如需查看所需的确切权限,请展开所需权限部分:

    所需权限

    如需设置多租户,您需要具备以下权限:

    • firebaseauth.configs.update
    • identitytoolkit.tenants.create

    您也可以使用自定义角色或其他预定义角色来获取这些权限。

启用多租户

  1. 在 Google Cloud 控制台中,前往 Identity Platform > 设置页面。
    前往“设置”

  2. 点击安全标签。

  3. 多租户部分,点击允许多租户

此操作会启用多租户并打开租户页面。

您现在可以创建第一个租户了。

创建租户

  1. 租户页面中,点击添加租户

  2. 名称字段中,输入租户的名称。 该名称不必是唯一的;Identity Platform 会自动分配不同的 ID。

  3. 点击保存

恭喜!您已创建 Identity Platform 租户。

选择租户

设置页面中,从限定到租户列表中选择您的租户。

每个租户都有自己的提供商和用户。选择租户后,您可以像管理非租户 Identity Platform 项目一样管理该租户。

停用多租户

如需停用多租户,请使用 Identity Toolkit API

后续步骤