

# Amazon CLI 的 Amazon IAM Identity Center 概念
<a name="cli-configure-sso-concepts"></a>

本主题介绍 Amazon IAM Identity Center（IAM Identity Center）的关键概念。IAM Identity Center 是一项基于云的 IAM 服务，通过与现有身份提供者（IdP）集成，可简化多个 Amazon Web Services 账户、SDK 和工具的用户访问管理。它通过集中式用户门户实现安全的单点登录、权限管理和审计，从而简化了组织的身份和访问管理。

**Topics**
+ [什么是 IAM Identity Center](#cli-configure-sso-concepts-what)
+ [术语](#cli-configure-sso-terms)
+ [IAM Identity Center 的工作原理](#cli-configure-sso-concepts-process)
+ [其他资源](#cli-configure-sso-concepts-resources)

## 什么是 IAM Identity Center
<a name="cli-configure-sso-concepts-what"></a>

IAM Identity Center 是一项基于云的身份和访问管理（IAM）服务，可帮助您集中管理对多个 Amazon Web Services 账户和业务应用程序的访问。

它提供一个用户门户，授权用户可以在该门户中使用其现有的公司凭证访问 Amazon Web Services 账户和获得相应权限的应用程序。这使组织能够实施一致的安全策略并简化用户访问管理。

无论您使用哪个 IdP，IAM Identity Center 都会将这些区别抽象出来。例如，您可以连接 Microsoft Azure AD，如博客文章 [IAM Identity Center 的下一个演进](https://www.amazonaws.cn/blogs/aws/the-next-evolution-in-aws-single-sign-on/)中所述。

**注意**  
有关使用持有者身份验证（不使用账户 ID 和角色）的信息，请参阅《Amazon CodeCatalyst 用户指南》中**的[进行设置以将 Amazon CLI 与 CodeCatalyst 一起使用](https://docs.amazonaws.cn/codecatalyst/latest/userguide/set-up-cli.html)。

## 术语
<a name="cli-configure-sso-terms"></a>

使用 IAM Identity Center 时的常用术语如下所示：

**身份提供者（IdP）**  
一个身份管理系统，例如 IAM Identity Center、Microsoft Azure AD、Okta 或您自己的公司目录服务。

**Amazon IAM Identity Center**  
IAM Identity Center 是 Amazon 自有的 IdP 服务。SDK 和工具以前称为 Amazon 单点登录，它们保留了 `sso` API 命名空间以实现向后兼容。有关更多信息，请参阅《Amazon IAM Identity Center 用户指南》**中的 [IAM Identity Center 重命名](https://docs.amazonaws.cn/singlesignon/latest/userguide/what-is.html#renamed)。

**Amazon Web Services 访问门户 URL、SSO 启动 URL、启动 URL**  
您组织唯一的 IAM Identity Center URL，用于访问您的授权 Amazon Web Services 账户、服务和资源。

**发布者 URL**  
您组织唯一的 IAM Identity Center 发布者 URL，用于通过编程方式访问您的授权 Amazon Web Services 账户、服务和资源。从版本 2.22.0 的 Amazon CLI 开始，发布者 URL 可以与启动 URL 互换使用。

**联合身份验证**  
在 IAM Identity Center 和身份提供者之间建立信任以启用单点登录（SSO）的过程。

**Amazon Web Services 账户**  
您通过 Amazon IAM Identity Center 为用户提供访问权的 Amazon Web Services 账户。

**权限集、Amazon 凭证、凭证、sigv4 凭证**  
预定义的权限集合，可以将其分配给用户或组以授予对 Amazon Web Services 服务 的访问权限。

**注册范围、访问范围、范围**  
范围是 OAuth 2.0 中的一种机制，用于限制应用程序对用户账户的访问。应用程序可以请求一个或多个范围，向应用程序签发的访问令牌将仅限于授予的范围。有关范围的信息，请参阅《IAM Identity Center 用户指南》**中的[访问范围](https://docs.amazonaws.cn/singlesignon/latest/userguide/customermanagedapps-saml2-oauth2.html#oidc-concept)。

**令牌、刷新令牌、访问令牌**  
令牌是在身份验证时向您颁发的临时安全凭证。这些令牌包含有关您的身份和您被授予的权限的信息。  
当您通过 IAM Identity Center 门户访问 Amazon 资源或应用程序时，系统会将您的令牌提供给 Amazon 以进行身份验证和授权。这使得 Amazon 能够验证您的身份，并确保您具有执行所请求操作所需的权限。  
身份验证令牌缓存在磁盘上的 `~/.aws/sso/cache` 目录下，JSON 文件名基于会话名称。

**会话**  
IAM Identity Center 会话是指用户通过身份验证并获得访问 Amazon 资源或应用程序的授权的时间段。当用户登录 IAM Identity Center 门户时，即会建立会话，并且该用户的令牌在指定的持续时间内有效。有关设置会话持续时间的更多信息，请参阅《Amazon IAM Identity Center 用户指南》**中的[设置会话持续时间](https://docs.amazonaws.cn/singlesignon/latest/userguide/howtosessionduration.html)。  
在会话期间，只要不同 Amazon 账户和应用程序的会话保持活动状态，您就可以在这些账户和应用程序之间导航，而无需重新进行身份验证。会话到期后，请重新登录以续订您的访问权限。  
IAM Identity Center 会话可帮助提供无缝的用户体验，同时还可以通过限制用户访问证书的有效性来强制实施最佳安全实践。

**具有 PKCE（代码交换的证明密钥）的授权代码授予**  
从版本 2.22.0 开始，代码交换的证明密钥（PKCE）是适用于带浏览器的设备的 OAuth 2.0 身份验证授予流程。利用 PKCE，可在桌面设备和移动设备上使用 Web 浏览器轻松安全地进行身份验证并获得对您的 Amazon 资源的访问权限。这是默认授权行为。有关 PKCE 的更多信息，请参阅《Amazon IAM Identity Center 用户指南》**中的[具有 PKCE 的授权代码授予](https://docs.amazonaws.cn/singlesignon/latest/userguide/customermanagedapps-saml2-oauth2.html#auth-code-grant-pkce)。

**设备授权授予**  
适用于带或不带 Web 浏览器的设备的 OAuth 2.0 身份验证授予流程。有关设置会话持续时间的更多信息，请参阅《Amazon IAM Identity Center 用户指南》**中的[设备授权授予](https://docs.amazonaws.cn/singlesignon/latest/userguide/customermanagedapps-saml2-oauth2.html#device-auth-grant)。

## IAM Identity Center 的工作原理
<a name="cli-configure-sso-concepts-process"></a>

IAM Identity Center 可与组织的身份提供者（例如 IAM Identity Center、Microsoft Azure AD 或 Okta）集成。用户对该身份提供者进行身份验证，然后 IAM Identity Center 会将这些身份映射到您的 Amazon 环境中的相应权限和访问权限。

以下 IAM Identity Center 工作流假设您已将 Amazon CLI 配置为使用 IAM Identity Center：

1. 在首选终端中运行 `aws sso login` 命令。

1. 登录 Amazon Web Services 访问门户，启动新会话。
   + 启动新会话时，您将收到刷新令牌和缓存的访问令牌。
   + 如果您已经有一个活动会话，将重用现有会话并且该会话将在现有会话过期时过期。

1. 根据您在 `config` 文件中设置的配置文件，IAM Identity Center 将采用相应的权限集，以便授予对相关 Amazon Web Services 账户和应用程序的访问权限。

1. Amazon CLI、SDK 和工具使用您担任的 IAM 角色调用 Amazon Web Services 服务（例如创建 Amazon S3 存储桶），直到该会话过期。

1. 系统每小时检查一次来自 IAM Identity Center 的访问令牌，并使用刷新令牌自动刷新该访问令牌。
   + 如果访问令牌已过期，SDK 或工具将使用刷新令牌来尝试获取新的访问令牌。然后比较这些令牌的会话持续时间，如果刷新令牌未过期，IAM Identity Center 将提供新的访问令牌。
   + 如果刷新令牌已过期，则不会提供新的访问令牌，并且您的会话已结束。

1. 会话将在刷新令牌过期后，或者当您使用 `aws sso logout` 命令手动注销时结束。缓存的凭证将被删除。要继续使用 IAM Identity Center 访问服务，您必须使用 `aws sso login` 命令启动新会话。

## 其他资源
<a name="cli-configure-sso-concepts-resources"></a>

其他资源如下所示。
+ [使用 Amazon CLI 配置 IAM Identity Center 身份验证](cli-configure-sso.md)
+ [教程：使用 IAM 身份中心在 Amazon CLI 中运行 Amazon S3 命令](cli-configure-sso-tutorial.md)
+ [安装或更新最新版本的 Amazon CLI](getting-started-install.md)
+ [Amazon CLI 中的配置和凭证文件设置](cli-configure-files.md)
+ 《Amazon CLI 版本 2 中参考》中的 [https://docs.amazonaws.cn/cli/latest/reference/configure/sso.html](https://docs.amazonaws.cn/cli/latest/reference/configure/sso.html)**
+ 《Amazon CLI 版本 2 中参考》中的 [https://docs.amazonaws.cn/cli/latest/reference/configure/sso-session.html](https://docs.amazonaws.cn/cli/latest/reference/configure/sso-session.html)**
+ 《Amazon CLI 版本 2 中参考》中的 [https://docs.amazonaws.cn/cli/latest/reference/sso/login.html](https://docs.amazonaws.cn/cli/latest/reference/sso/login.html)**
+ 《Amazon CLI 版本 2 中参考》中的 [https://docs.amazonaws.cn/cli/latest/reference/sso/logout.html](https://docs.amazonaws.cn/cli/latest/reference/sso/logout.html)**
+ 《Amazon CodeCatalyst 用户指南》**中的[设置为将 Amazon CLI 与 CodeCatalyst 一起使用](https://docs.amazonaws.cn/codecatalyst/latest/userguide/set-up-cli.html)
+ 《Amazon IAM Identity Center 用户指南》**中的 [IAM Identity Center 重命名](https://docs.amazonaws.cn/singlesignon/latest/userguide/what-is.html#renamed)
+ 《IAM Identity Center 用户指南》**中的 [OAuth 2.0 访问范围](https://docs.amazonaws.cn/singlesignon/latest/userguide/customermanagedapps-saml2-oauth2.html#oidc-concept)
+ 《Amazon IAM Identity Center 用户指南》**中的[设置会话持续时间](https://docs.amazonaws.cn/singlesignon/latest/userguide/howtosessionduration.html)
+ 《IAM Identity Center 用户指南》**中的[入门教程](https://docs.amazonaws.cn/singlesignon/latest/userguide/tutorials.html)