Skip to content

fix: oidc issues and gcp support - #23

Merged
LutfiGarzon merged 13 commits into
mainfrom
fix/oidc-issues-and-gcp-support
Apr 29, 2026
Merged

LutfiGarzon merged 13 commits into
mainfrom
fix/oidc-issues-and-gcp-support

Conversation

@LutfiGarzon

@LutfiGarzon LutfiGarzon commented Apr 29, 2026 •

Copy link
Copy Markdown
Owner

Why

The OIDC feature had no design review coverage and accumulated several operational,
UX, and architectural gaps since its initial implementation. Providers were missing
prerequisites, templates were incomplete, error handling was fragile, and there was no
multi-cloud runtime support beyond AWS. This PR brings the feature to
production-readiness with full test coverage (186 tests, 33 files, 100% OIDC feature
coverage).

What

🔴 Operational fixes

  • TLS thumbprint warnings — generated AWS templates now include comments warning
    that thumbprints may need rotation
  • Azure GitLab audience — fixed from https://gitlab.com to
    api://AzureADTokenExchange with a note for GitLab CI config
  • Missing azuread_service_principal — Azure template now creates the SP
    alongside the application
  • AWS STSClient credential resolution — explicit empty credentials for the
    anonymous AssumeRoleWithWebIdentity call
  • GCP attribute_mapping — expanded with attribute.repository,
    attribute.actor (GitHub) and attribute.project_path, attribute.ref (GitLab)
  • GCP service account collision — account_id now includes env suffix to
    prevent conflicts across environments

🟢 Minor fixes

  • Deprecated Buffer.from() → Uint8Array in AWS provider
  • Templates pass terraform fmt — integration test validates all three
    templates against the terraform binary

🟡 Design improvements

  • Branch overrides removed — --env prod/--env qa no longer silently change
    your branch input
  • Wildcard ban removed — release/* and other wildcard branches are now allowed
  • Overwrite prompt — vault oidc prompts before replacing existing .tf files;
    --force skips it
  • --dry-run — preview template to stdout without writing

🚀 Multi-cloud runtime (vault ci)

  • CloudKmsProvider interface — contract-based decryption: AwsKmsProvider,
    AzureKeyVaultProvider, GcpKmsProvider
  • Azure Key Vault — REST API via client_assertion grant + Key Vault decrypt
  • GCP Cloud KMS — REST API via STS token exchange + Cloud KMS decrypt
  • VAULT_CLOUD_PROVIDER — explicit override; errors if multiple cloud env vars
    are set without it
  • vault ci --check — verify OIDC→KMS chain without vault file or command
    execution
  • Full error-case coverage — missing env vars for all three clouds are tested
  • GitLab CI_JOB_JWT_V2 deprecation — documented fallback with warning

📚 Documentation

  • README: OIDC setup section with cloud/CI provider table
  • README: CI runtime env vars for AWS, Azure, GCP
  • README: GitHub Actions workflow example with id-token: write
  • README: KMS key is user-provided (templates handle trust, not encryption)
  • vault ci --help expanded with cloud env var reference

…e in try/catch

- Throw instead of process.exit(1) for unsupported cloud providers
- Wrap fs.writeFile in try/catch with descriptive error message
- Remove p.cancel calls in favor of thrown errors

Tests: add coverage for GCP/unsupported provider throws and writeFile failure
…ation

- Replace all 4 process.exit(0) cancel paths with thrown errors
- Add repo format validation (must match owner/repo)
- Use cancelSymbol for proper isCancel mocking

Tests: add cancel coverage for CI provider, repo, and branch prompts;
add repo format validation tests
…ub provider

- Add SessionToken presence check before KMS client creation
- Validate audience is non-empty before GitHub OIDC token fetch

Tests: add missing SessionToken rejection test;
add empty/whitespace audience rejection tests
… to templates

- Add azuread_application resource to Azure template (was referencing non-existent resource)
- Add Terraform output blocks for AWS (role ARN) and Azure (application object ID)

Tests: add output block assertions for both AWS and Azure templates;
add azuread_application resource presence test
- New generateGcpTemplate() with google_iam_workload_identity_pool,
  google_iam_workload_identity_pool_provider, and
  google_service_account_iam_member resources
- Supports GitHub Actions and GitLab CI providers
- Environment mapping (prod→main, qa→release/*)

Tests: 7 tests covering GitHub, GitLab, env mapping,
pool resource, service account binding, and unsupported CI
@LutfiGarzon LutfiGarzon changed the title Fix/OIDC issues and gcp support fix: oidc issues and gcp support Apr 29, 2026
… template

The GCP template referenced google_service_account.vault.name and
var.project_id without creating them. Now self-contained like AWS/Azure.

Tests: add assertions for variable and service_account presence
- Add thumbprint rotation warning comments to AWS template
- Fix Azure GitLab audience to api://AzureADTokenExchange (was https://gitlab.com)
- Add missing azuread_service_principal to Azure template
- Fix AWS STSClient to use explicit empty credentials (AssumeRoleWithWebIdentity is anonymous)
- Document vault ci AWS-only limitation in ci.ts
- Expand GCP attribute_mapping with repository/project_path and actor/ref
- Replace deprecated Buffer.from() with Uint8Array in AWS provider
- Add env suffix to GCP service_account account_id to prevent collisions

Tests: 156 passing
…eprecation warning

- Remove env-based branch overrides (prod→main, qa→release/*); user branch is always respected
- Remove wildcard ban from TUI branch validator
- Add file-exists check with p.confirm prompt before overwriting .tf
- Add --force flag to skip overwrite prompt
- Add CI_JOB_JWT_V2 deprecation warning in GitLab provider

Tests: 159 passing
…terface

- Define CloudKmsProvider interface (name + decrypt contract)
- AwsKmsProvider adapter wrapping existing decryptWithAwsKms
- AzureKeyVaultProvider via REST API (client_assertion grant + Key Vault decrypt)
- GcpKmsProvider via REST API (STS token exchange + Cloud KMS decrypt)
- Refactor ci.ts to detect cloud provider from env vars and route to correct provider
- Each cloud provider gets the correct OIDC audience for JWT requests
- Backward compatible: existing VAULT_AWS_ROLE_ARN env vars still work

Tests: 171 passing, 33 test files
- Fix double blank line in Azure template concatenation
- Add terraform fmt - integration tests for all three templates
- Tests gracefully skip if terraform binary is not installed

Tests: 174 passing
…and structural validation

- VAULT_CLOUD_PROVIDER env var to explicitly select cloud when multiple are configured
- Error if multiple cloud vars set without VAULT_CLOUD_PROVIDER
- README: CI runtime env var docs for AWS, Azure, GCP with GitLab audience note
- Expanded vault ci --help with cloud env var reference
- Error-case tests for missing Azure/GCP required env vars
- Template structural validation tests for dangling references

Tests: 182 passing
…larification

- vault oidc --dry-run: preview template to stdout without writing
- vault ci --check: verify OIDC→KMS chain without vault file or command execution
- README: GitHub Actions workflow example with id-token: write
- README: clarify KMS key is user-provided (templates handle trust, not encryption)
- Test for overwrite cancel (p.isCancel branch)

Tests: 186 passing
@LutfiGarzon
LutfiGarzon merged commit 3c9cde1 into main Apr 29, 2026
4 checks passed
@LutfiGarzon
LutfiGarzon deleted the fix/oidc-issues-and-gcp-support branch April 29, 2026 20:02
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant