如何使用第三方 IdP 為 Amazon Cognito 使用者集區設定 IAM Identity Center?
3 分的閱讀內容
0
我想使用第三方身分提供者 (IdP) 為 Amazon Cognito 使用者集區設定 AWS IAM Identity Center。
解決方法
使用應用程式用戶端和網域名稱建立 Amazon Cognito 使用者集區
注意:如果您擁有包含應用程式用戶端的使用者集區,請繼續執行啟動 IAM Identity Center 並新增使用者一節。
請完成下列步驟:
- 建立新的應用程式。
- 建立 Amazon Cognito 首碼網域,格式如下:https://cognitoexample.auth.region.amazoncognito.com。或者,建立自訂網域。如需詳細資訊,請參閱設定使用者集區網域。
- (選用) 將品牌套用至受管理的登入頁面。
啟動 IAM Identity Center 並新增使用者
注意:如果您擁有正常運作的 IAM Identity Center 環境,請繼續執行設定 SAML 應用程式一節。
請完成下列步驟:
- 查看 IAM Identity Center 先決條件和注意事項。
- 啟動 IAM Identity Center。
**注意:**在執行個體類型,您必須選擇在 AWS Organizations 管理帳戶中建立的 IAM Identity Center 組織執行個體。 - 確認您的身分來源,然後建立使用者。
設定 SAML 應用程式
請完成下列步驟:
- 開啟 IAM Identity Center console (IAM Identity Center 主控台)。
- 在導覽窗格中,選擇 Applications (應用程式)。
- 選擇 **Add application **(新增應用程式),然後在 Setup preference (設定偏好設定) 下選取 I have an application I want to set up (我有一個想要設定的應用程式)。
- 在 Application type (應用程式類型),選取 SAML 2.0,然後選擇 Next (下一步)。
- 在 Configure application (設定應用程式) 頁面上,輸入顯示名稱和說明。
- 記下 IAM Identity Center SAML 中繼資料檔案的網址,或選擇 Download (下載) 超連結來下載該檔案。
- 在 Application metadata (應用程式中繼資料) 下,選擇 Manually type your metadata values (手動輸入中繼資料值)。然後,輸入以下值:
在 Application Assertion Consumer Service (ACS) URL (應用程式判斷提示消費者服務 (ACS) 網址),輸入 https://domain-prefix.auth.region.amazoncognito.com/saml2/idpresponse。
在 Application SAML audience (應用程式 SAML 對象),輸入 urn:amazon:cognito:sp:userpool-id。
**注意:**將 domain-prefix 替換為您的網域首碼,將 region 替換為您的 AWS 區域,並將 userpool-id 替換為您的使用者集區 ID。 - 選擇 Submit (提交)。
- 在您應用程式的 Details (詳細資訊)頁面上,選擇 Actions (動作) 下拉式清單。
- 選擇 Edit attribute mappings (編輯屬性對應),然後輸入下列屬性:
在 User attribute in the application (應用程式中的使用者屬性),保留預設的主題。
在 Maps to this string value or user attribute in IAM Identity Center (對應到 IAM Identity Center 的此字串值或使用者屬性),輸入 ${user:subject}。
在 Format (格式),輸入 Persistent。
在 User attribute in the application (應用程式中的使用者屬性),輸入 email。
在 Maps to this string value or user attribute in IAM Identity Center (對應到 IAM Identity Center 的此字串值或使用者屬性),輸入 ${user:email}。
在 Format (格式),輸入 Basic。
**注意:**當您登入時,IAM Identity Center 會將屬性對應傳送到 Amazon Cognito。請確定您已對應所有使用者集區所需的屬性。如需可用對應屬性的詳細資訊,請參閱支援的外部身分提供者屬性。 - 選擇 Submit (提交)。
- 在 Assigned users and groups (指派的使用者和群組) 區段下,選擇 Assign users and groups (指派使用者和群組)。
- 找到您的使用者,然後選擇 Assign (指派)。
在您的使用者集區中將 IAM Identity Center 設定為 SAML IdP
若要在您的使用者集區中設定 SAML IdP,請參閱在使用者集區中新增和管理 SAML 身分提供者。當您指定 SAML 提供者屬性對應時,請在 SAML attribute (SAML 屬性) 欄位中輸入有效的電子郵件。在 User pool attribute (使用者集區屬性) 中,選取 email (電子郵件)。
如需提供者名稱和識別碼的資訊,請參閱 SAML 身分提供者名稱和識別碼。
使用使用者集區應用程式用戶端整合身分提供者
請完成下列步驟:
- 開啟 Amazon Cognito console (Amazon Cognito 主控台)。
- 在導覽窗格中,選擇 User pools (使用者集區)。
- 在 Applications (應用程式) 下,選擇 App clients (應用程式用戶端)。
- 選取應用程式用戶端。
- 在 Login pages (登入頁面) 區段,選擇 Edit (編輯)。
- 在 Identity providers (身分提供者) 區段,選取您的 IdP。
- 選擇 Save changes (儲存變更)。
測試設定
若要測試服務提供者 (SP) 發起的登入,請完成以下步驟:
- 開啟 Amazon Cognito 主控台,然後在應用程式用戶端的 Login pages (登入頁面) 索引標籤上選擇 View login page (查看登入頁面)。或者,建立登入端點網址。 使用以下範例命名模式,並將範例值替換為您的值:
https://my-user-pool.auth.us-east-1.amazoncognito.com/login?response_type=code&client_id=a1b2c3d4e5f6g7h8i9j0k1l2m3&redirect_uri=https://example.com
在 OAuth 2.0 grant types (OAuth 2.0 授權類型),選擇 Implicit grant (隱式授權)。然後在請求網址中,將 response_type 設定為 token。 - 在 Login pages (登入頁面) 索引標籤上,選取 IAM Identity Center IdP。
如果您的瀏覽器將您重新導向至應用程式用戶端的回呼網址,則表示您已成功以使用者身分登入。使用者集區權杖會顯示在 Web 瀏覽器網址列的網址中。
注意:若要跳過此步驟,請建立具有下列命名模式的授權端點網址:
https://yourDomainPrefix.auth.region.amazoncognito.com/oauth2/authorize?response_type=token&identity_provider=samlProviderName&client_id=yourClientId&redirect_uri=redirectUrl&scope=allowedOauthScopes - 輸入使用者憑證,然後選擇 Login (登入)。
當 Amazon Cognito 使用程式碼或權杖將您重新導向到回呼網址時,設定就完成了。
若要測試身分提供者 (IdP) 發起的登入,請完成下列步驟:
- 開啟 Amazon Cognito console (Amazon Cognito 主控台)。
- 在導覽窗格中,選擇 User pools (使用者集區),然後選取您的使用者集區。
- 在導覽窗格中,選擇 Social and external provider (社交和外部提供者)。
- 選取您的 IdP,然後在 Identity provider information (身分提供者資訊) 區段中選擇 Edit (編輯)。
- 在 IdP-initiated SAML sign-in (IdP 發起的 SAML 登入) 區段中,選擇 Accept SP-initiated and IdP-initiated SAML assertions (接受 SP 發起的和 IdP 發起的 SAML 判斷提示)。
**注意:**您可以將其他 SAML 提供者新增至接受具有 IdP 發起登入的 SAML 提供者的應用程式用戶端。從應用程式用戶端中移除其他社交或 OpenID Connect (OIDC) 提供者或 Cognito 使用者集區目錄。 - 選擇 Save changes (儲存變更)。
- 開啟 IAM Identity Center 主控台,然後選取您的 SAML 2.0 應用程式。
- 選擇 Actions (動作) 下拉式功能表,然後選擇 Edit configuration (編輯組態)。
- 在 Application properties (應用程式屬性) 下,新增以下中繼狀態值:
identity_provider=identity-provider-name&client_id=app-client-id&redirect_uri=callback-url&response_type=token&scope=openid+email
**注意:**將範例值替換為您的值。 - 選擇 Submit (提交)。
- 在導覽窗格中,選擇 Settings (設定)。
- 在 Identity source (身分來源) 區段,複製 AWS 存取入口網站網址並在瀏覽器中開啟。
- 輸入使用者憑證,然後選擇 Login (登入)。
- 選取 Cognito 應用程式。
如果 Amazon Cognito 使用程式碼或權杖將您重新導向到回呼網址,則設定已完成。
相關資訊
- 語言
- 中文 (繁體)

AWS 官方已更新 4 個月前
沒有評論
