ivanfocsa/multi-cloud-workload-identity-lab
GitHub: ivanfocsa/multi-cloud-workload-identity-lab
该项目通过 GitHub OIDC 实现 AWS、GCP 和 Azure 三大云平台的工作负载身份联合,用短期令牌替代长期静态密钥。
Stars: 0 | Forks: 0

# 多云工作负载身份实验
[](#)
[](#)
[](#)
[](#)
本实验旨在验证来自 GitHub Actions 工作负载的 AWS、Google Cloud 和 Azure 之间的工作负载身份联合。目标很简单:用短期、可审计的身份 token 替换长期有效的云密钥。
## 本项目演示的内容
- 在云交换之前的 GitHub OIDC token 验证。
- 限定于单一存储库和分支的 AWS IAM 角色信任策略。
- 带有属性映射和条件的 GCP Workload Identity Pool。
- 针对 Microsoft Entra 工作负载的 Azure 联合身份凭据。
- 用于安全审查的可重复证据检查清单。
## 架构
```
GitHub Actions job
|
| OIDC token
v
+------+-------------------+----------------------+
| AWS STS | GCP WIF | Microsoft Entra ID |
| AssumeRoleWithWebIdentity| Token exchange | Federated credential|
+--------------------------+----------------------+--------------------+
| | |
v v v
Short-lived AWS role Short-lived GCP SA Short-lived Azure SP
```
## 存储库结构图
```
.
|-- docs/
| |-- oidc-contract.json
| |-- threat-model.md
| `-- validation-checklist.md
|-- examples/github-actions/
| `-- multi-cloud-oidc.yml
|-- scripts/
| `-- Test-OidcContract.ps1
`-- terraform/
|-- aws/
|-- azure/
`-- gcp/
```
## 快速开始
1. 查看 `docs/oidc-contract.json` 并替换存储库占位符。
2. 仅部署您想首先验证的云服务提供商。
3. 将生成的角色、提供商或客户端 ID 添加为 GitHub 存储库变量。
4. 将 `examples/github-actions/multi-cloud-oidc.yml` 复制到 `.github/workflows/` 中。
5. 运行工作流并存储 `docs/validation-checklist.md` 中列出的证据。
## 本地 token 合约检查
当您在本地保存了 GitHub OIDC token 时:
```
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -Force
./scripts/Test-OidcContract.ps1 `
-TokenPath ./samples/github-oidc.jwt `
-ContractPath ./docs/oidc-contract.json
```
在云服务提供商信任 token 之前,该脚本会检查颁发者、受众和 subject 前缀。
## 参考
- GitHub OIDC 加固概述:https://docs.github.com/actions/security-for-github-actions/security-hardening-your-deployments/about-security-hardening-with-openid-connect
- 在 GitHub Actions 中使用 AWS OIDC:https://docs.github.com/actions/security-for-github-actions/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services
- GCP Workload Identity Federation:https://docs.github.com/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-google-cloud-platform
- Microsoft 工作负载身份联合:https://learn.microsoft.com/en-us/entra/workload-id/workload-identity-federation
## 安全说明
本存储库专为授权实验而构建。它不包含云凭据、私钥或特定于租户的标识符。请将真实的账户 ID 和租户 ID 保存在 GitHub 变量或您的安全参数存储中。
标签:AI合规, ECS, GitHub Actions, IPv6, OIDC, PowerShell, Terraform, 云安全配置, 多云架构, 自动笔记, 身份联邦, 零长存凭证