Skip to content

feat(storage): support refreshed OSS AssumeRole credentials - #6097

Open
30bef100w wants to merge 1 commit into
Tencent:mainfrom
30bef100w:feat/oss-assume-role-5068
Open

30bef100w wants to merge 1 commit into
Tencent:mainfrom
30bef100w:feat/oss-assume-role-5068

Conversation

@30bef100w

Copy link
Copy Markdown
Contributor

Description

System-owned OSS storage can now use OSS_AUTH_TYPE=ram_role_arn. A low-privilege caller key assumes OSS_ROLE_ARN, and the Alibaba Cloud credential SDK caches and refreshes the temporary credentials used by OSS requests. The adapter serializes provider access and shares it across the main/temporary buckets and repeated service resolutions.

  • Support session name, duration, optional inline session policy and external ID; document the configuration and forward it through Docker Compose.
  • Route environment-owned storage initialization, backend resolution and connectivity tests through the role provider. Workspace-owned backends retain their own static credentials and cannot select the deployment role.
  • Keep temporary keys/tokens in memory, include the token in signed requests and presigned URLs, and return sanitized errors without falling back to the caller's key.
  • Preserve the default static AK/SK behavior. Unknown auth modes fail explicitly.

Presigned links cannot outlive the STS token. The credential SDK does not accept a request context: an already-running fetch may complete its bounded network wait before cancellation is returned. This adds ARN-based AssumeRole only; it does not implement ECS instance metadata roles from #4115/#4116.

Type of Change

  • ✨ New feature
  • 📚 Documentation update
  • 🧪 Test
  • 🔧 Configuration / Build / CI

Related Issue

Fixes #5068

Testing

Local tests use a TLS STS fixture and an HTTP OSS fixture with dummy credentials. They cover AssumeRole parameters and signature presence, refresh before expiry, GET/PUT presigned security tokens, 20 concurrent requests sharing one refresh, sanitized failures without source-key fallback, deployment/workspace identity separation, and shared main/temporary bucket credentials.

Passed with Go 1.26.0:

go test -race ./internal/application/service/file -count=1
go test ./internal/application/service/file -run 'TestOSSRole|TestOSSEnvironmentRole' -count=1 -v
go test ./internal/application/service -run '^TestEnvironmentOSSRejectsUnknownAuthWithoutStaticFallback$|^TestStorageBackend|^TestResolveFileService|^Test.*Global.*Storage' -count=1 -v
go test ./internal/container -run 'OSS|FileService' -count=1
golangci-lint run --new-from-rev=<base> ./internal/application/service/file/... ./internal/application/service ./internal/container

The container command verifies compilation; no matching container tests exist. Changed Go files pass gofmt; the patch passes git diff --check. Compose parses with the standard Ruby YAML parser and forwards all six new settings.

The service regression test fails against the original implementation (unknown deployment auth silently uses static keys) and passes with this change. No live Alibaba Cloud account was used. Full-repository checks were not run; validation was scoped to the affected storage packages. On macOS, tests used SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX15.4.sdk for compatibility with the installed linker.

Checklist

  • Diff whitespace check passes against the base
  • Changed source files are formatted
  • Targeted tests for the changed packages/components pass
  • Diff-scoped lint passes
  • Full-repository checks were run (focused validation and limits documented above)
  • Self-reviewed the code
  • Added/updated tests covering the change
  • Updated related documentation
  • No intentional breaking changes

This contribution was prepared with AI assistance.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: OSS 支持 STS AssumeRole(ram_role_arn)临时凭证,无需长期 AK/SK

1 participant