

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 设置客户托管 OAuth 2.0 应用程序以实现可信身份传播
<a name="customermanagedapps-trusted-identity-propagation-set-up-your-own-app-OAuth2"></a>

要为可信身份传播设置客户托管 OAuth 2.0 应用程序，必须先将其添加到 IAM Identity Center。使用以下过程将您的应用程序添加到 IAM Identity Center。

**Topics**
+ [步骤 1：选择应用程序类型](#customermanagedapps-trusted-identity-propagation-set-up-your-own-app-OAuth2-select-app-type)
+ [步骤 2：指定应用程序详细信息](#customermanagedapps-trusted-identity-propagation-set-up-your-own-app-OAuth2-specify-app-details)
+ [步骤 3：指定身份验证设置](#customermanagedapps-trusted-identity-propagation-set-up-your-own-app-OAuth2-specify-authentication-settings)
+ [步骤 4：指定应用程序凭证](#customermanagedapps-trusted-identity-propagation-set-up-your-own-app-OAuth2-specify-application-credentials)
+ [步骤 5：审核和配置](#customermanagedapps-trusted-identity-propagation-set-up-your-own-app-OAuth2-review-and-configure)

## 步骤 1：选择应用程序类型
<a name="customermanagedapps-trusted-identity-propagation-set-up-your-own-app-OAuth2-select-app-type"></a>

1. 打开 [IAM Identity Center 控制台](https://console.amazonaws.cn/singlesignon)。

1. 选择**应用程序**。

1. 选择**客户托管**选项卡。

1. 选择**添加应用程序**。

1. 在**选择应用程序类型**页面，选择**设置首选项**下的**我有想设置的应用程序**。

1. 在 “**应用程序类型**” 下，选择 **OAuth 2.0**。

1. 选择**下一步**，进入下一页：[步骤 2：指定应用程序详细信息](#customermanagedapps-trusted-identity-propagation-set-up-your-own-app-OAuth2-specify-app-details)。

## 步骤 2：指定应用程序详细信息
<a name="customermanagedapps-trusted-identity-propagation-set-up-your-own-app-OAuth2-specify-app-details"></a>

1. 在**指定应用程序详细信息**页面的**应用程序名称和描述**下，输入应用程序的**显示名称**，如 **MyApp**。然后，输入**描述**。

1. 在**用户和组分配方法**下，选择下列选项之一：
   + **需要分配** - 仅允许分配给此应用程序的 IAM Identity Center 用户和组访问该应用程序。

     应用程序图块可见性-只有直接或通过群组分配分配到应用程序的用户才能在访问门户中查看应用程序图块，前提是**应用程序在 Amazon Web Services 访问门户中的 Amazon Web Services 可见性**设置为 “**可见**”。
   + **不需要分配** - 允许所有授权的 IAM Identity Center 用户和组访问此应用程序。

     应用程序图块可见性-除非应用程序在 Amazon Web Services 访问门户中的可见**性设置为 “不可见”，否则登录 Amazon Web Services 访问门户的所有用户**都可以**看到应用程序**图块。

1. 在**Amazon Web Services 访问门户**下，输入用户可以访问应用程序的 URL，并指定应用程序图块在 Amazon Web Services 访问门户中是可见还是不可见。如果选择**不可见**，则即使已分配的用户也无法查看应用程序磁贴。

1. 在**标签（可选）**下，选择**添加新标签**，然后为**键**和**值（可选）**指定值。

   有关标签的信息，请参阅 [为资源添加标签 Amazon IAM Identity Center](tagging.md)。

1. 选择**下一步**，进入下一页：[步骤 3：指定身份验证设置](#customermanagedapps-trusted-identity-propagation-set-up-your-own-app-OAuth2-specify-authentication-settings)。

## 步骤 3：指定身份验证设置
<a name="customermanagedapps-trusted-identity-propagation-set-up-your-own-app-OAuth2-specify-authentication-settings"></a>

要将支持 OAuth 2.0 的客户托管应用程序添加到 IAM Identity Center，您必须指定可信令牌颁发者。可信令牌发行者是创建签名令牌的 OAuth 2.0 授权服务器。这些令牌用于对发起请求以访问 Amazon 托管应用程序（接收端应用程序）的应用程序（请求端应用程序）进行授权。

1. 在**指定身份验证设置**页面的**可信令牌发布者**下，执行以下任一操作：
   + 使用现有的可信令牌发布者：

     在要使用的可信令牌发布者的名称旁边，选择其复选框。
   + 添加新的可信令牌发布者：

     1. 选择**创建可信令牌发布者**。

     1. 将打开一个新的浏览器标签页。按照 [如何向 IAM Identity Center 控制台添加可信令牌发布者](setuptrustedtokenissuer.md#how-to-add-trustedtokenissuer) 中的步骤 5 至步骤 8 操作。

     1. 完成这些步骤后，返回您正用于设置应用程序的浏览器窗口，然后选择刚刚添加的可信令牌发布者。

     1. 在可信令牌发布者列表中，选中刚刚添加的可信令牌发布者名称旁边的复选框。

        选择可信令牌发布者后，将出现**配置选定的可信令牌发布者**部分。

1. 在**配置选定的可信令牌发布者**下，输入 **Aud 声明**。**Aud 声明**用于确定可信令牌发布者生成的令牌的目标受众（接收者）。有关更多信息，请参阅 [Aud 声明](trusted-token-issuer-configuration-settings.md#trusted-token-issuer-aud-claim)。

1. 要让用户在使用此应用程序时无需重新进行身份验证，请选择**启用刷新令牌授予**。选中后，此选项将每 60 分钟刷新一次会话的访问令牌，直到会话过期或用户结束会话。

1. 选择**下一步**，进入下一页：[步骤 4：指定应用程序凭证](#customermanagedapps-trusted-identity-propagation-set-up-your-own-app-OAuth2-specify-application-credentials)。

## 步骤 4：指定应用程序凭证
<a name="customermanagedapps-trusted-identity-propagation-set-up-your-own-app-OAuth2-specify-application-credentials"></a>

完成此过程中的步骤，为应用程序指定用于与可信应用程序执行令牌交换操作的凭证。这些凭证将在一个基于资源的策略中使用。该策略要求您指定一个主体，该主体必须有权执行该策略中指定的操作。即使可信应用程序位于同一个 Amazon Web Services 账户中，**您也必须指定一个主体**。

**注意**  
在使用策略设置权限时，请仅授予执行任务所需的权限。为此，您可以定义在特定条件下可以对特定资源执行的操作，也称为最低权限权限。

该策略需要使用 [https://docs.amazonaws.cn/singlesignon/latest/OIDCAPIReference/API_CreateTokenWithIAM.html](https://docs.amazonaws.cn/singlesignon/latest/OIDCAPIReference/API_CreateTokenWithIAM.html) API 操作。有关该策略的更多信息以及可根据您的环境需求调整的示例，请参阅 [IAM Identity Center 的基于资源的策略示例](iam-auth-access-using-resource-based-policies.md)。

1. 在**指定应用程序凭证**页面，执行以下任一操作：
   + 要快速指定一个或多个 IAM 角色：

     1. 选择**输入一个或多个 IAM 角色**。

     1. 在**输入 IAM 角色**下，指定现有 IAM 角色的 Amazon 资源名称 (ARN)。要指定 ARN，请使用以下语法。由于 IAM 资源是全球资源，因此，ARN 的区域部分是空的。

        ```
          arn:aws:iam::{{account}}:role/{{role-name-with-path}}
        ```

        有关更多信息，请参阅*Amazon Identity and Access Management 用户*指南 ARNs中的[使用基于资源的策略进行跨账户访问](https://docs.amazonaws.cn/IAM/latest/UserGuide/access_policies-cross-account-resource-access.html#access_policies-cross-account-using-resource-based-policies)和 [IAM](https://docs.amazonaws.cn/IAM/latest/UserGuide/reference_identifiers.html#identifiers-arns)。
   + 要手动编辑策略（如果指定非Amazon 凭据，则为必填项），请执行以下操作：

     1. 选择**编辑应用程序策略**。

     1. 在 JSON 文本框中键入或粘贴文本，修改策略。

     1. 解决策略验证过程中产生的任何安全警告、错误或常规警告。有关更多信息，请参阅 *Amazon Identity and Access Management 用户指南*中的[验证 IAM 策略](https://docs.amazonaws.cn/IAM/latest/UserGuide/access_policies_policy-validator.html)。

1. 选择**下一步**，进入下一页：[步骤 5：审核和配置](#customermanagedapps-trusted-identity-propagation-set-up-your-own-app-OAuth2-review-and-configure)。

## 步骤 5：审核和配置
<a name="customermanagedapps-trusted-identity-propagation-set-up-your-own-app-OAuth2-review-and-configure"></a>

1. 在**审查和配置**页面中，审查您所做的选择。要进行更改，请选择所需的配置部分，选择**编辑**，然后进行所需的更改。

1. 完成后，选择**添加应用程序**。

1. 您添加的应用程序将显示在**客户托管的应用程序**列表中。

1. 在 IAM Identity Center 中设置客户托管的应用程序后 Amazon Web Services 服务，必须指定一个或多个用于身份传播的受信任的应用程序。这样，用户就能够登录客户托管的应用程序，并访问可信应用程序中的数据。

   有关更多信息，请参阅 [指定可信的应用程序](trustedidentitypropagation-using-customermanagedapps-specify-trusted-apps.md)。