workforce (Identity Center) users を headless に管理する (M2M)¶
backend service から interactive login なしで organization の workforce (Identity Center) users を管理します — service access key (AK/SK) と STS のみを使用します。このパターンは AWS に忠実です。key が role を assume し、その role の temporary credentials が IdC users を管理する permission を持ちます。
AK/SK → assume-role → ASIA temp creds → FGAI-HMAC + X-FGAI-Security-Token
→ /identity/v1/organizations/{orgId}/identity-center/users…
なぜ role (key を直接使わないのか) なのか。Workforce-user management は、すべての call で identitycenter:User:{verb} に対して authorization されます。その permission は、organization の management account に存在する role に付与されます。あなたはその role を assume して操作します。これにより、長期有効な service key の permission を軽く保ち、AWS IAM + STS と同じ形に従います。
Prerequisites: a service access key (see Integrate an external app with AK/SK) and the ability to sign requests with FGAI-HMAC-SHA256 (see IAM roles and STS AssumeRole). All calls below are one signed HTTPS request to https://api.flexgalaxy.ai.
role は management account に存在する¶
WorkforceAdminRole は常に organization の management account({mgmtAccountId})に存在する。Identity Center directory がそこに anchoring されているためである。したがってその FRN は frn:{mgmtAccountId}:iam:role/WorkforceAdminRole であり、permission policy は frn:{mgmtAccountId}:identitycenter:user/* に対する identitycenter:User:* を grant する。どの path に従うかは、あなたの service principal がどこに存在するかによって決まる:
Path |
service principal の場所… |
role の取得方法… |
|---|---|---|
Primary — platform-seeded(external integrator) |
あなた自身の tenant account (management account ではありません) |
platform が management account 内の role をあなたのためにseedします。その trust は、あなたの principal の FRN を account 間で許可し、 |
Secondary — self-authored(management-account のみ) |
management account 自体 |
あなたは role、その managed policy、および attachment を自分で作成し、その後それを assume します。 |
primary path は外部 integrator にとって標準である。service key は自分の account に固定されるため、management account 内で role を author できない。その role は platform が seed する。self-author path は、principal がすでに management account 内に存在する場合 のみ 利用可能である。
2 つの重要な制約¶
まずこれらを読んでください — どちらかを誤ると silent 403 IMPLICIT_DENY になります。これらは両方の paths で成り立ちます (platform-seeded role はすでに満たしています)。
permission は role に attached された MANAGED policy で付与されます。 role の inline policy はこの path では尊重されません。grant は
POST …/roles/{roleId}/policiesで attached される customer-managediam-policyです。policy
Resourceは Identity Center user FRN と一致しなければなりません。frn:{mgmtAccountId}:identitycenter:user/*(または*)である必要があります。より狭い、または誤ったResourceは一致せず、call は denied されます。
Primary path — platform-seeded role を assume する (external integrator)¶
service principal はあなた自身の tenant account に存在します。onboarding 中に platform は organization の management account に WorkforceAdminRole を seed します。この role には、account 間であなたの principal FRN を許可し、shared-secret sts:ExternalId を要求する trust policy があります。何かを作成する必要はありません。assume して操作します。
onboarding で得られるもの:
role FRN —
frn:{mgmtAccountId}:iam:role/WorkforceAdminRoletrust condition 用の
externalIdshared secretあなたの
{orgId}(およびその{mgmtAccountId})
1. Assume the role → temporary credentials¶
POST /identity/v1/sts/assume-role — ロールが 別の (管理) アカウントにある場合でも、ユーザーの 静的 サービスキー (AKIA) で署名します。これはクロスアカウントの assume-role です。ロールの信頼ポリシーがゲートになります。
{
"roleFrn": "frn:{mgmtAccountId}:iam:role/WorkforceAdminRole",
"roleSessionName": "workforce-batch-42",
"durationSeconds": 3600,
"externalId": "shared-secret-xyz"
}
response は ASIA… credentials(accessKeyId, secretAccessKey, sessionToken, expiration)を返す。durationSeconds は [900, role.maxSessionDuration] に clamp される。誤った、または欠落した externalId は credentials なし で 403 を返す。
2. Manage workforce users with the temporary credentials¶
各呼び出しを ASIA credentials(FGAI-HMAC-SHA256)で署名し、sessionToken を設定した X-FGAI-Security-Token header を追加する。
… /identity/v1/organizations/{orgId}/identity-center/users
Method |
Path |
Purpose |
|---|---|---|
|
|
workforce users を一覧表示する |
|
|
workforce user を招待する |
|
|
workforce user を読み取る |
|
|
workforce user を更新する |
|
|
無効化 / 有効化 |
|
|
login credential を reset する |
|
|
workforce user を削除する |
各 operation は identitycenter:User:{verb} に対してチェックされます。seeded role の managed policy では、このチェックは ALLOW を返します。
mgmtAccountId の見つけ方¶
role FRN、policy Resource、{orgId} path はすべて organization の management account を指す。organization からそれを解決する: organization を読む(GET /organizations/v1/{orgId})— その management account id が mgmtAccountId である。self-author(management-account)principal の場合、これは単に自分自身の account id である。
長時間実行ジョブ: session duration と re-assume¶
Assumed-role credentials は short-lived です — durationSeconds は [900, role.maxSessionDuration] に clamped されます(default 3600)。長時間の headless batch は、現在の expiration の前に role を re-assume し、新しい ASIA credentials で signing を継続する必要があります。401 を待つのではなく、expiry より少し前(例: lifetime の 80%)に refresh してください。
Failures¶
signature がない、または無効 →
401。Role が存在しない or その trust policy が拒否している(principal が誤っている、または
externalIdが誤っている)→403(区別不能なため、呼び出し元は別アカウントの role を探索できない)。credentials は返されない。Permission が付与されていない (managed policy が attach されていない、または
Resourceが一致しない) →identity-center/userscall で403。
関連項目¶
Integrate an external app with AK/SK — FGAI-HMAC signing。
IAM roles and STS AssumeRole — roles、trust policies、STS reference。
[FRN format](https://docs.flexgalaxy.ai/dev/dotid/frn-format/)