API 认证与 JWT 校验¶
The platform's external authentication model — which host and route admit FGAI-HMAC-SHA256, which admit an OIDC bearer token, and the exact refusal for the other scheme — is stated once in External authentication model. This page covers the second half of that model: how a receiving service validates a bearer token it IS declared to accept.
JWT bearer authentication applies to browser/BFF flows and explicit service-audience workload contracts. It is not the CLI or public tenant-control-plane credential. Human bearer tokens, including platform-admin tokens, are never CLI credentials; platform administration remains private to the admin-console web app.
See CLI authentication for the signed public-API contract.
Realm¶
DotID issues tokens from named realms on the platform Keycloak. Each realm issues its own JWTs from its own signing key.
Realm |
适用主体 |
issuer claim 示例 |
|---|---|---|
|
The single tenant entry realm — account-root users, workforce members of accounts, and the platform-level workforce |
Every account and organization is resolved inside flexgalaxy — tenancy rides token claims
(account_id, user_type, org membership), never a realm name. The legacy per-account (acc-*) and
per-org (idc-*) realm model was retired: those realms no longer exist and a token claiming an
acc-*/idc-* issuer cannot be validly issued today. The platform additionally operates
dedicated gate realms for its own surfaces (fgai-admins for platform administration,
staging-access for the staging gate, insider-doc-viewers for the insider portal) — your service
accepts those only if it is one of those platforms. Account-owned service users are non-interactive
and use the Account boundary. These identity populations are isolated and are never merged by
matching email.
租户绑定:account_id 和 user_type 声明¶
flexgalaxy realm 发出的访问令牌携带两个声明,用于描述已认证 subject 的租户绑定:account_id 和 user_type。
{
"iss": "https://auth.flexgalaxy.ai/auth/realms/flexgalaxy",
"sub": "9e0f6f96-2f57-4f49-84ef-8d4d12d4f5e1",
"account_id": "11111111-1111-1111-1111-111111111111",
"user_type": "root"
}
account_id— the DotID account UUID the subject is bound to. It is emitted for both account-root users and workforce members of an account. It means "this user belongs to this tenant" — nothing more. It is not the account name and not a realm name.user_type— subject 如何绑定到该账户:root— 账户的 root 用户。workforce— 账户的 workforce 成员。
规则:
严格从
user_type == "root"推导账户 root 状态。 不要仅因存在account_id就推断为 root — workforce 用户同样携带account_id,但不是 root。把“有account_id”当成“是 root”会静默地把每个 workforce 成员提升为等同 root。使用
account_id解析调用方的租户(用于每请求作用域限定以及构建 PDP principal 上下文)。不要从邮箱、用户名或 realm 名称推导账户身份。未绑定的
flexgalaxy用户(例如平台管理员)两个声明都不会收到。如果account_id缺失,调用方未绑定到租户;如果user_type缺失或不是root,不要将调用方视为账户 root。改为通过适当的平台管理员、workforce、服务用户或 workload 身份路径路由请求。
这些声明是身份上下文,不是授权授予。它们告诉服务已验证令牌属于哪个租户,以及 subject 是否是该账户的 root;它们并不表示调用方可以执行某个特定服务操作。第一方服务仍必须对任何由策略控制的账户/资源操作调用 DotID PDP。
校验服务收到的 JWT¶
A receiving service accepts a JWT only where the declaration in
External authentication model admits one: a bearer surface, or a route the
route table marks fgai-hmac+bearer, bearer or workload-jwt. Public tenant routes on the API
edge implement the signed AK/SK and STS path (temporary ASIA credentials, available to any
principal via sts assume-role); JWT support on another audience does not satisfy that public
contract, and on an HMAC-only route the service refuses the bearer rather than validating it.
具体而言,你的 JWT 校验器必须:
从 token header / payload 中提取
issclaim。Verify the issuer is the platform realm — exact match:
https://auth.flexgalaxy.ai/auth/realms/flexgalaxy. Reject any other issuer. Do not prefix-match realm families: the legacyacc-*/idc-*families no longer exist, and an exact match is what rejects a rogue realm that merely shares a prefix.从
<issuer>/protocol/openid-connect/certs拉取该 realm 的 JWKS。缓存这些密钥(DotID 会按计划轮换;请遵循Cache-Controlheader)。根据 JWKS 校验签名,按 token 的
kidheader 匹配密钥。校验标准 claim:
exp(未过期)、nbf(若存在,未早于生效时间)、iat(结合时钟偏移做合理性检查)、aud(匹配你服务的受众标识)。校验授权逻辑所依赖的任何服务专属 claim(例如
realm_access.roles、groups)。
DotID's own services implement exactly this pattern. There is exactly one customer-facing issuer, so
a validator is a single exact-match check on flexgalaxy — there is no open-acceptance or
prefix-allowlist variant to choose between, and none to mix.
Discovering this resource (RFC 9728)¶
A 401 from a bearer-admitting surface — a browser host, or a machine route declared
fgai-hmac+bearer, bearer or workload-jwt — names where to find this resource's OAuth 2.0
protected-resource metadata:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer resource_metadata="https://api.flexgalaxy.ai/.well-known/oauth-protected-resource"
A 401 from an HMAC-only machine route does NOT carry that challenge. It challenges the
credential the route actually accepts:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: FGAI-HMAC-SHA256 realm="dotid"
The distinction is deliberate: following an OAuth discovery pointer from a route that refuses OAuth bearer tokens sends a client to a credential exchange that cannot succeed there. The public metadata document still exists and is still anonymous — it just is not advertised by a route that will not accept what it describes.
Fetch that URL to get the RFC 9728 metadata document for the host you called:
curl -sS https://api.flexgalaxy.ai/.well-known/oauth-protected-resource
{
"resource": "https://api.flexgalaxy.ai",
"bearer_methods_supported": ["header"]
}
Those are the two fields a client needs; the document also carries the other RFC 9728 registry
fields. The advertised URL is always https, always carries no port, and always names the host your
request carried — a client may follow it as-is. The document is public: discovery precedes
authentication, so it needs no credential.
FlexGalaxy.AI is multi-tenant, but tenancy is carried in token claims rather than separate realms:
every account authenticates against the single platform realm, so the metadata document deliberately
does not enumerate authorization servers. The authorization server is the platform realm — use its
/.well-known/openid-configuration.
常见错误¶
状态 |
含义 |
排查方向 |
|---|---|---|
|
The credential is absent, invalid, or of the wrong family for this route. |
On JWT-bearing browser/workload routes, verify the bearer token's |
|
token 校验通过,但 PDP 返回了 |
检查响应体 —— 它包含 |
|
principal 对象、action 或 resource FRN 不合法。 |
规范资源语法与解析方法参见 FRN 格式。 |
|
API 版本不匹配 —— 请求被发送到了已废弃的路径。 |
面向开发者的公共 API 使用 |
联合工作负载 token¶
DotID 还会通过 RFC 8693 token exchange 为从外部 OIDC issuer(GitHub Actions、GitLab CI)联合而来的工作负载身份颁发 access token。你的服务对其执行的校验与校验任何其他 DotID 颁发的 JWT 相同:相同的 realm JWKS、相同的 iss / aud / exp 规则。唯一的区别是,token 的 sub 是 DotID 工作负载身份 ID,而不是 human 或 service-user ID,并且 token 还带有一个额外的 federated_subject 自定义 claim,形状为 {issuer, sub},用于记录来源 CI subject 以便进行审计关联。
仅将 federated_subject claim 视为审计元数据,绝不要将其用于授权决策。与其他所有 DotID 颁发的 token 一样,aud、sub 和 scope claim 才是授权边界。
有关交换契约(即 CI 调用以获取此 token 的端点,而不是你的服务为消费它所做的校验),请参见 workload-federation.md。