Skip to content

fix: STS AssumeRole returns empty credentials when endpoint has no path (#205) - #247

Open
jiuker wants to merge 3 commits into
minio:mainfrom
jiuker:fix-sts-credentials-205
Open

fix: STS AssumeRole returns empty credentials when endpoint has no path (#205)#247
jiuker wants to merge 3 commits into
minio:mainfrom
jiuker:fix-sts-credentials-205

Conversation

@jiuker

@jiuker jiuker commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Fixes issue #205: temporary credentials (access_key / secret_key / session_token) returned by AssumeRoleProvider are empty. Root cause: when the STS endpoint has no path (e.g. http://host:9000), the SigV4 signature is computed with an empty CanonicalURI, while the actual request is sent to '/', causing signature verification to fail and leaving credentials empty.

Also aligns all STS provider request parameters with the minio-go reference implementation and fixes the XML root node paths used for credentials parsing.

Bug fix (issue #205):

  • AssumeRoleProvider constructor: normalize an empty endpoint path to '/', keeping the signed CanonicalURI consistent with the actual request URI (conditional assignment only - does not override user-defined paths such as /minio/sts)
  • Add an AssumeRoleProvider() regression test: success path asserts all three temporary credential fields are non-empty; failure path asserts the error is diagnosable via creds.err

Align STS provider parameters with minio-go:

  • Add token_revoke_type to every provider (AssumeRoleProvider, WebIdentityClientGrantsProvider/ClientGrantsProvider/WebIdentityProvider, LdapIdentityProvider, CertificateIdentityProvider), added to the request body only when non-empty
  • LdapIdentityProvider additionally gains policy, duration_seconds, and config_name
  • Jwt struct gains access_token / refresh_token; the WebIdentity flow now sends WebIdentityAccessToken / WebIdentityRefreshToken
  • All new parameters are appended at the end with defaults, backward compatible

XML parsing fix:

  • All STS response parsing now uses the full root path with the Response prefix (e.g. AssumeRoleResponse/AssumeRoleResult), avoiding parse failures

Files changed: include/miniocpp/providers.h, src/providers.cc, tests/tests.cc

Summary by CodeRabbit

  • New Features

    • Added support for access and refresh tokens in web identity authentication flows.
    • Added token-revocation configuration for supported temporary credential providers.
    • Expanded LDAP and certificate authentication options, including policy, duration, and configuration settings.
    • Forwarded additional authentication parameters when requesting temporary credentials.
  • Bug Fixes

    • Improved parsing of temporary credential responses.
    • Standardized default STS endpoint paths.
    • Added validation when obtaining temporary credentials to detect incomplete responses.

…th (minio#205)

Fixes issue minio#205: temporary credentials (access_key / secret_key / session_token) returned by AssumeRoleProvider are empty. Root cause: when the STS endpoint has no path (e.g. http://host:9000), the SigV4 signature is computed with an empty CanonicalURI, while the actual request is sent to '/', causing signature verification to fail and leaving credentials empty.

Also aligns all STS provider request parameters with the minio-go reference implementation and fixes the XML root node paths used for credentials parsing.

Bug fix (issue minio#205):
- AssumeRoleProvider constructor: normalize an empty endpoint path to '/', keeping the signed CanonicalURI consistent with the actual request URI (conditional assignment only - does not override user-defined paths such as /minio/sts)
- Add an AssumeRoleProvider() regression test: success path asserts all three temporary credential fields are non-empty; failure path asserts the error is diagnosable via creds.err

Align STS provider parameters with minio-go:
- Add token_revoke_type to every provider (AssumeRoleProvider, WebIdentityClientGrantsProvider/ClientGrantsProvider/WebIdentityProvider, LdapIdentityProvider, CertificateIdentityProvider), added to the request body only when non-empty
- LdapIdentityProvider additionally gains policy, duration_seconds, and config_name
- Jwt struct gains access_token / refresh_token; the WebIdentity flow now sends WebIdentityAccessToken / WebIdentityRefreshToken
- All new parameters are appended at the end with defaults, backward compatible

XML parsing fix:
- All STS response parsing now uses the full root path with the Response prefix (e.g. AssumeRoleResponse/AssumeRoleResult), avoiding parse failures

Files changed: include/miniocpp/providers.h, src/providers.cc, tests/tests.cc
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@jiuker, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 44 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: bd27a561-b676-4d16-9b43-9707fcb37777

📥 Commits

Reviewing files that changed from the base of the PR and between 0f731f5 and 1851b8f.

📒 Files selected for processing (1)
  • tests/tests.cc

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 16854ae4-f8a0-4f2a-9c23-dcbd122848cc

📥 Commits

Reviewing files that changed from the base of the PR and between be495d0 and 0f731f5.

📒 Files selected for processing (1)
  • tests/tests.cc
💤 Files with no reviewable changes (1)
  • tests/tests.cc

📝 Walkthrough

Walkthrough

Provider constructors now accept token-revocation settings and expanded LDAP options. Web identity providers forward JWT access and refresh tokens. STS response parsing uses qualified paths. An AssumeRole test validates temporary credentials.

Changes

Provider authentication updates

Layer / File(s) Summary
Provider API contracts
include/miniocpp/providers.h
Jwt exposes access and refresh tokens. Provider constructors accept token-revocation settings. LDAP accepts policy, duration, and configuration name values.
STS and web identity request flow
src/providers.cc, tests/tests.cc
STS requests include token-revocation settings. Web identity requests forward JWT tokens. Response parsing uses qualified paths. The AssumeRole test validates returned credentials.
LDAP and certificate request flow
src/providers.cc
LDAP requests include configured policy, duration, token-revocation, and configuration values. Certificate requests include token-revocation settings. Both use qualified response paths.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant AssumeRoleProvider
  participant WebIdentityProvider
  participant STSEndpoint
  participant XMLParser
  Client->>AssumeRoleProvider: Request temporary credentials
  AssumeRoleProvider->>STSEndpoint: Send AssumeRole with TokenRevokeType
  Client->>WebIdentityProvider: Request web identity credentials
  WebIdentityProvider->>STSEndpoint: Send JWT access and refresh tokens
  STSEndpoint-->>XMLParser: Return qualified STS response XML
  XMLParser-->>AssumeRoleProvider: Parse temporary credentials
Loading

Poem

I’m a rabbit with tokens tucked tight,
Revoking by type in the moonlight.
JWTs hop through the STS gate,
XML paths now point straight.
LDAP and certs join the run—
Fresh credentials for everyone!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: fixing empty STS AssumeRole credentials when the endpoint has no path.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/tests.cc`:
- Line 1571: Remove the redundant “Success path” comment immediately preceding
the temporary-credentials condition in the test, leaving the condition and
surrounding test logic unchanged.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 13f6a380-f180-40a3-a5ed-23846969d7fe

📥 Commits

Reviewing files that changed from the base of the PR and between e764b82 and be495d0.

📒 Files selected for processing (3)
  • include/miniocpp/providers.h
  • src/providers.cc
  • tests/tests.cc

Comment thread tests/tests.cc Outdated
@jiuker jiuker linked an issue Aug 12, 2026 that may be closed by this pull request
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.

STS 获取临时凭证

1 participant