使用 AK/SK 集成外部应用¶
这是仅使用 服务访问密钥 (AK/SK) 将外部应用程序与 FlexGalaxy.AI 平台集成的端到端指南,不需要交互式用户会话、不需要管理控制台,也不需要自助注册。如果你正在构建一个代表客户预置账号、编写策略、检查授权并管理用户的门户或后端,这就是完整路径。
集成模型¶
Your application is a service principal. During onboarding you are issued one service-user
access key (an access-key id + secret). From then on you sign every AK/SK request with
FGAI-HMAC-SHA256 against the public API gateway at https://api.flexgalaxy.ai, under the
/identity/v1/…, /accounts/v1/…, /organizations/v1/… capability paths.
备注
There is no interactive step in this model. You do not capture a human's login, you do not call the browser/console gateway, and you do not self-register the app (app registration is done once during onboarding). One service-user credential signs every surface this page marks as AK/SK — it does not sign the handful of surfaces the tables below mark JWT only. Which credential each public route accepts is declared once, in the API auth model; this page is the integrator's view of the AK/SK half of it.
你的密钥绑定到一个账号。每次调用都在该账号的作用域内求值:你只能读取和更改密钥所属账号中的资源。Cross-account access 是一项独立且显式的 delegation feature — 不是单个密钥会隐式完成的事情。
1. Get your credential¶
Sign in to the FlexGalaxy console, open Service users,
create one if you have none, and Create access key on it — the id and secret are shown
once. The full walkthrough (and where the name you pass to --auth comes from) is the
help site's Service users page; to issue additional keys or rotate your own, see
[CLI & service authentication](https://docs.flexgalaxy.ai/dev/dotid/cli-authentication/).
A key is an access-key id (e.g. AKIA…) and a secret; temporary (STS) keys start with ASIA…
and also require a session token.
2. Sign a request (FGAI-HMAC-SHA256)¶
Every request you sign carries these headers:
Header |
值 |
|---|---|
|
|
|
请求时间戳, |
|
原始请求 body 的十六进制 SHA-256(无 body 的 GET 则为空字符串) |
|
仅对临时( |
签名是对规范请求执行的 AWS-SigV4 形态 HMAC:
canonicalRequest =
METHOD \n
canonical_path \n # the public request path, e.g. /identity/v1/accounts/{id}/users
canonical_query \n # sorted, percent-encoded query string ("" if none)
canonical_headers \n # each SignedHeader, lowercased "name:value", sorted, newline-terminated
signed_headers \n # the SignedHeaders list, ";"-joined
hex_sha256(body)
The signing key is derived HMAC by HMAC:
kDate = HMAC("FGAI4"+secret, date) → kRegion = HMAC(kDate, region) →
kService = HMAC(kRegion, service) → kSigning = HMAC(kService, "fgai4_request"), and
Signature = hex(HMAC(kSigning, canonicalRequest)). Sign over the public host and path you
call (https://api.flexgalaxy.ai) — the gateway preserves them for verification. Requests are rejected
outside a ±5-minute clock skew, so keep your clock in sync.
小技巧
host、x-fgai-date 和 x-fgai-content-sha256 必须包含在你的 SignedHeaders 中。对内容哈希进行签名,正是将请求正文绑定到签名的机制。
重要
The <region> and <service> segments of the Credential are not free-form — they are part
of the signing key derivation and are checked against the API you call:
<region>is alwaysap-northeast-1.<service>is per-product. Use the value for the API family you are calling:API family
Paths
<service>DotID identity / accounts / organizations
/identity/v1/…,/accounts/v1/…,/organizations/v1/…identitySoftware-licensing / marketplace (bazaar)
/v1/integrations/licensing/…, otherbazaarproduct APIsbazaar(orsoftware-licensing)
A signature scoped to the wrong service is rejected with 403 credential_scope_mismatch
(note: 403, distinct from a 401 invalid_signature, which means the HMAC itself did not match —
usually a mishandled secret, clock skew beyond ±5 min, or a canonical-request mismatch). If you use
the reference signer, pass --service bazaar for licensing/marketplace calls —
its default is identity.
A Python reference signer (fgai_hmac_sign.py, standard-library only) that reproduces this
canonical layout and key derivation byte-for-byte is available on request from your onboarding
contact — use it rather than reimplementing the byte layout by hand.
3. Which capabilities are AK/SK vs. web-only¶
integrator 需要的一切都在 AK/SK gateway 上。少数真正交互式 flow 按设计仍仅限 browser。
能力 |
在 AK/SK gateway 上? |
路径 |
|---|---|---|
Accounts — 读取/管理 |
✅ |
|
Organizations & OUs — 完整 CRUD、account→OU 放置、tree |
✅ |
|
** 成员账户生命周期** 读作/重命名/暂停/恢复/拆卸成员账户 |
✅ (management credential) |
|
Enterprise onboarding — bulk-create placeholder accounts |
✅ (management credential) |
|
Onboarding — promote an account to ACTIVE (first operator) |
✅ (management credential) |
|
Account-lifecycle status — placeholder/active roster with |
✅ (management credential) |
|
PassPort app-entry routing — resolve ONBOARDING vs APP on Open/deep-link |
⚠️ workforce JWT only (not AK/SK) |
|
PassPort application (read) |
✅ (public) |
|
Workforce users — list / invite / disable / enable / remove |
⚠️ 仅 console/JWT(非 AK/SK) |
Identity Center directory |
IAM / programmatic users — 创建 / 列表 / 删除 |
✅ |
|
服务用户 |
✅ |
|
Workload identities(federated) |
✅ |
|
客户托管 policy 编写(按名称) |
✅ |
|
Policy simulator |
✅ |
|
应用注册 |
一次性(onboarding) |
— |
Root / tenant sign-up;交互式 password/MFA reset |
❌ 仅 web |
备注
Workforce users(人员,通过 email onboarded,具有角色和 PENDING/ACTIVE/DISABLED 状态)与 IAM/programmatic users(machine identities,创建时已启用)是不同的表面。它们在 Identity Center directory 中管理。
4. Required fields & common pitfalls¶
这些会让集成方产生真实返工 — 构建前请先阅读。
authorizerequiresprincipal(withaccount_id,user_id,user_typeandic_session),actionandresource, and — for permission-set checks —principal.ps_id. A missing or blank required field, or an unreadable body, returns a400with a structured error body (status,message); the401is reserved for the credential and signature.principal.ic_sessionis a primitive boolean on the wire: send it explicitly —falsefor a normal IAM-user check,truefor an Identity Center federated session, which then also carriesps_id. Omitting it (or sendingnull) is not a default offalse: the body becomes unreadable and the call returns400Malformed request body. See [Policy simulator](https://docs.flexgalaxy.ai/dev/dotid/pdp-authorize/). The simulator also requires theIamPolicySimulateAccesspermission attached to the signing service user — a key alone is refused with403 policy-simulate-required.Batch authorize 使用
checks,不是requests。 body 为{ "principal": {…}, "context": {…}, "checks": [ { "action": …, "resource": … }, … ] },response 为{ "results": [ … ] },顺序相同。所有 checks 共享一个 principal/context。Default-deny。 没有匹配的
Allow即为DENY(IMPLICIT_DENY);显式Deny始终优先(EXPLICIT_DENY)。授权限定在你的 key 所属账户内。400means the body;401means the credential. A missing required field or a malformed body is a400rendered in the request dispatch, not a401— so if a request you believe is signed correctly returns401, it is the signature/key, not the body shape. If it returns400, readmessage: a validation failure names the failing field in its wire spelling (snake_case), while an unreadable body reportsMalformed request body.workforce/account call 上出现
403表示 account scope 问题。 path 中的{accountId}必须是你的 key 绑定的账户。access-key-expired也是403。签署 body hash。
X-FGAI-Content-SHA256必须是你发送的精确字节的 SHA-256;body 与其签名 hash 不匹配会被拒绝。
5. End-to-end walkthrough¶
一个最小 integrator flow,全部使用同一个 signed key:
Provision tenant tree。 创建账户及其 organization/OUs(
/accounts/v1/…,/organizations/v1/…),并将 accounts 放入 OUs。Author policy. Create an account-scoped customer-managed policy by name and reference it from a permission set (
/identity/v1/accounts/{id}/policies,/permission-sets/{id}/customer-policies).分配访问权限。 将 permission set 附加到 principals / OUs(在作用域内 assignments 会向下级联读取)。
检查授权。 在你的 app 执行动作前,询问 PDP(
/identity/v1/authorize或/authorize/batch)该 principal 是否可以执行。Manage employees。 Workforce(store-employee)users 属于 Identity Center directory,而不是 account-scoped surface。这目前是 console/JWT 流程(
/identity/v1/organizations/{orgId}/identity-center/users)— 请参阅下面的 Workforce users。(较早的 account-scoped AK/SK surface/identity/v1/accounts/{id}/workforce-users已退休。)
每一步都是一次签名 HTTPS 调用到 https://api.flexgalaxy.ai。请参阅 [External developer API examples](https://docs.flexgalaxy.ai/dev/dotid/examples/external-developer-api/index/) 中的完整请求示例。
管理成员账户¶
一个组织的管理账户通过AK/SK管理其成员账户——不需要控制台,也不需要成员账户登录。 用管理账户的密钥签名这些电话:
行动 |
调用 |
|---|---|
读取成员账户 |
|
重命名成员账户 |
|
暂停成员账户 |
|
恢复已中止的成员账户 |
|
切除成员账户 |
|
Authorization is by management account. Every operation above is allowed only when the account
your key is bound to is the management account of {orgId}, and {accountId} is a member of
that organization. A key bound to any other account gets a 403.
Suspend is reversible. suspend freezes a member account and signs its users out; restore
brings it back to active. Because both are authorized by your management credential — independent
of the member account itself — you can always restore a member you suspended; suspend is never a
one-way door.
备注
The management account cannot suspend itself (400). To wind down the whole organization,
delete the organization rather than suspending its management account.
授权范围(公司账户经理)¶
有时你想要一个帐户来管理整个公司的帐户**——例如,一个区域经理,他应该去他们公司下的每一家商店,包括后来开设的商店——而不给他们其他任何东西。 一个组织的管理账户作为OU → 管理者 对AK/SK的授权:它从一个OU公司向管理者账户** 分配一个特定的许可范围。 从那时起,经理的这一范围就超过OU的子树上的每一个当前和未来的账户——只有那些。 在 OU 中设置的新商店会自动覆盖; OU 之外没有任何东西。
用 ** 管理账户** 键签名 :
行动 |
调用 |
|---|---|
创建代表团 |
|
现职代表团名单 |
|
撤销代表团资格 |
|
Authorized by the management account. Every call is allowed only when the account your key is bound to is the management account of
{orgId}. Any other account gets a403.Outcomes. A valid delegation returns
201. The OU must belong to{orgId}and each permission set must already be effective at that OU (assigned on the OU or an ancestor) — if it is not, the call is rejected with422(you cannot delegate authority the OU does not itself hold). A caller that is not the management account gets403.** 范围仅窄。 ** 管理者永远不能获得比OU控股更多的收益,如果管理者重新授权,每一次跳动都可能会缩小范围,但永远不会扩大范围.
Revocation is immediate.
DELETE …/delegations/{delegationId}drops the Manager's inherited access at once — the next authorization check reflects it, with no cached grants.
小技巧
This complements the per-account transitive delegation authoring path
(/identity/v1/accounts/{account_id}/delegations), which an account uses to delegate its own
scope upward. Both are now reachable over AK/SK: the account path is authorized for the account
itself or its org's management account; the OU → Manager path above is management-account only.
Workforce users (Identity Center directory)¶
account-scoped
/identity/v1/accounts/{id}/workforce-usersAK/SK surface 已退役,现在返回404。 如果你曾基于它构建,调用将返回 404 — 不要使用它。
Workforce (store-employee) users 的规范位置是组织的 Identity Center directory:
曾经是(已退役,账号级,AK/SK) |
现在(规范的、org-scoped) |
|---|---|
|
|
|
|
|
|
|
|
|
|
Programmatic access: Identity Center directory 对每个 operation 做授权并接受 STS temporary credentials,因此你可以 headlessly 管理 workforce users — 不需要 console。流程:
以 IdC user 身份,通过 STS session-token flow 获取临时
ASIA…credentials(可通过 console 或 CLI 使用)。这些 credentials 与 gateway 无关 — 它们可用于 public API。使用 FGAI-HMAC-SHA256 为你的
/identity/v1/organizations/{orgId}/identity-center/users调用签名,并包含X-FGAI-Security-Tokenheader(临时凭证要求 — 见 §2)。公共网关会保留路径,因此请对你实际调用的路径签名(§2)。
每个操作都会根据 identitycenter:User:{verb}(List/Read/Create/Update/Delete/ Disable/Enable/ResetPassword)检查,因此调用用户必须持有覆盖性的 Identity Center permission set(例如 IdentityCenterFullAccess),并已在组织的 management account 中分配;没有该权限的调用者会得到 403。Bearer-JWT/console path 继续保持不变。
纯 AK/SK(无 interactive user)? 如果你只有 service access key,并希望 headlessly 管理 workforce users,请 assume 一个携带 identitycenter:User:* 权限的 role,并使用其 temporary credentials 操作 — 参见 Manage workforce (Identity Center) users headlessly (M2M)。
IAM roles & AssumeRole¶
service credential(或 JWT user)可以创建按账户划分的 IAM roles,并 assume 它们以获取临时、有范围限制的 credentials — 这是忠实于 AWS 的 cross-account 机制:
POST /identity/v1/accounts/{account_id}/roles— create a role (trust policy + attached permission policies).POST /identity/v1/sts/assume-role— 按roleFrn扮演角色;返回临时ASIA凭证(与X-FGAI-Security-Tokenheader 一起使用),这些凭证会在该角色所属账号内以其权限执行操作。
同一组织内账户之间的跨账户管理使用每个成员账户中自动预置的 OrganizationAccountAccessRole:management account 代入该 role 来管理该成员的 IAM。
同一个 assume-role 机制也支持无头 workforce-user 管理 — 见 Manage workforce (Identity Center) users headlessly (M2M)。
Enterprise onboarding (bulk accounts)¶
Onboard a company's accounts in bulk instead of looping single POST /accounts/v1/provision
calls. All three calls are authorized by management-account ownership (your key's account
must be the org's management account) — the AWS-faithful model.
Create placeholders —
POST /organizations/v1/{orgId}/account-batches{ "accounts": [ { "name": "account-shibuya-01" }, { "name": "account-shibuya-02" } ] }
→
202 Acceptedwith the placeholder roster; each account startsstatus: "PLACEHOLDER",realm_status: "NONE":{ "org_id": "…", "placeholders_created": 2, "accounts": [ { "account_id": "…", "name": "account-shibuya-01", "status": "PLACEHOLDER", "realm_status": "NONE", "version": 0 } ] }
Promote an account to ACTIVE (first operator grant) —
POST /organizations/v1/{orgId}/onboarding/accounts/{account_id}/grant-operator→200with the account nowstatus: "ACTIVE". The sibling…/{accountId}/provision-service-useronboards the account's first service user and completes account activation — the current model has no per-account realms.Surface live status —
GET /organizations/v1/{orgId}/account-lifecycle[?status=PLACEHOLDER]→200with the ordered roster; every row carriesstatus(PLACEHOLDER/MATERIALIZING/ACTIVE/CLOSED) andrealm_status.
PassPort app-entry routing¶
On a PassPort deep-link / Open, resolve whether to route the user to onboarding or the
app: POST /passport/v1/app-entry/resolve
({ "app_id": …, "account_id": …, "user_type": "workforce" }) → the routing decision keyed on
the target account's lifecycle.
重要
app-entry/resolve authenticates the workforce user's DotID session (a Keycloak
Bearer JWT), not a service AK/SK — it routes that signed-in user and verifies they are an
assigned member of the account. Call it with the end-user's DotID access token (the one your app
receives from OIDC login), which the public gateway forwards. A service AK/SK gets 401 here by
design. The read surface GET /passport/v1/applications/{appId} is public.
Declaring a split onboarding entry. By default every account resolves to the app's
homepage_url (route APP). To route not-yet-active (PLACEHOLDER / MATERIALIZING) accounts to
a distinct onboarding page, set surfaces.app_launch.onboarding_entry_url (a relative browser
path, e.g. /welcome) when you register the app via POST /developer/v1/services. The surfaces
object is required on registration; its app_launch slice takes launch_path,
required_action, resource_frn_pattern, allowed_redirect_paths, and the optional
onboarding_entry_url. Omit onboarding_entry_url and app-entry always returns APP.