本页面介绍了一些常见工作负载身份联合错误的解决方法。
Trusted Cloud API 不接受从 SecurityTokenService
颁发的凭据
SecurityTokenService
API 返回的访问令牌是联合访问令牌。虽然大多数 Trusted Cloud API 都支持身份联合,但某些 API 方法可能会受到限制。如需查看限制列表,请参阅身份联合:产品和限制。
如果您遇到以下错误,可能是因为您尝试将联合访问令牌用于不支持此类令牌的服务。
{
"error": {
"code": 401,
"message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED",
}
}
如需消除此错误,请通过调用 GenerateAccessToken
将联合访问令牌交换为不受限制的访问令牌。如需了解详情,请参阅使用身份联合获取短期有效的凭据。
将身份提供方列入许可名单以与工作负载身份联合搭配使用
如果您尝试将不允许的身份提供商配置为工作负载身份池提供商,则会遇到以下错误:
FAILED_PRECONDITION: Precondition check failed.
- '@type': type.googleapis.com/google.rpc.PreconditionFailure
violations:
- description: "Org Policy violated for value: '{PROVIDER}'."
subject: orgpolicy:projects/{PROJECT}/locations/global/workloadIdentityPools/{POOL}
type: constraints/iam.workloadIdentityPoolProviders
如需解决此问题,请按照限制身份提供方配置中的说明将身份提供方列入许可名单,以便与工作负载身份联合搭配使用。
输入 JWK 不是有效的 JSON 格式
如果您在配置 OIDC 提供方时收到 Input JWK is
not in a valid json format
错误,可能是因为 Trusted Cloud不支持使用自签名证书保护的端点。具体而言,不支持 x5c
和 x5t
字段,必须将其从 OIDC JWK 中移除。
如需解决 JWK 的问题,请执行以下操作:
修改 JWK,并移除
x5c
(X.509 证书链)和x5t
(X.509 证书 SHA-1 指纹)字段。{ "kty": "RSA", "use": "sig", "kid": "example-key-id", "alg": "RS256", "n": "base64url-modulus", "e": "AQAB" }
验证其余 JWK 字段的格式是否正确,如 OIDC 规范中所述。
使用更新后的 JWK 配置 OIDC 提供方。
连接到给定凭据的颁发者时出错
如果您收到以下错误,可能是因为 Trusted Cloud by S3NS 无法提取 IdP 的 OIDC 元数据文档或 JWKS:
{
"error": "invalid_grant",
"error_description":"Error connecting to the given credential's issuer."
}
发生此错误的原因通常是端点未配置为可通过公共互联网访问。如需消除此错误,请检查 OIDC 端点是否公开可用并且符合 OIDC 规范。如需了解详情,请参阅准备外部身份提供方。
如果您仍然遇到错误,请检查令牌颁发者(令牌的 iss
声明)是否正确。
映射的 google.subject 声明超出 127 字节的限制
如果您收到以下错误,是因为 SecurityTokenService
API 收到的传入凭证生成的 google.subject
声明超出了字符数限制:
{
"error": "invalid_request",
"error_description":"The size of mapped attribute google.subject exceeds the 127 bytes limit. Either modify your attribute mapping or the incoming assertion to produce a mapped attribute that is less than 127 bytes."
}
如需解决此问题,请使用 extract
函数移除不必要的字符,并从较长的声明中提取唯一的主体标识符,例如:
google.subject=assertion.sub.extract('/users/{sub_claim}')
错误 429 请求过多
如果您在通过 SecurityTokenService
API 请求令牌时收到 429 Too Many Requests
错误,则表示您的 Trusted Cloud 项目超出了该 API 的速率配额限制。
该错误包含类似于以下内容的消息:
{
"error": "quota_exceeded",
"error_description":"The request was throttled due to rate limit: sts.googleapis.com/requests. Please retry after a few seconds."
}
如需解决此问题,请确定错误消息中提供的 sts.googleapis.com/requests
指标名称,在 “IAM 配额”页面中找到相应的指标名称,确认使用百分比超过配额,然后申请增加配额。