Skip to content

Fix/s3v4 signer and oauth2 token#3504

Open
abhishekkumar2024 wants to merge 3 commits into
apache:mainfrom
abhishekkumar2024:fix/s3v4-signer-and-oauth2-token
Open

Fix/s3v4 signer and oauth2 token#3504
abhishekkumar2024 wants to merge 3 commits into
apache:mainfrom
abhishekkumar2024:fix/s3v4-signer-and-oauth2-token

Conversation

@abhishekkumar2024

Copy link
Copy Markdown

Rationale for this change

Are these changes tested?

Are there any user-facing changes?

Abhishek Kumar and others added 3 commits June 15, 2026 11:19
… invalid Bearer token

Two bugs affecting REST catalog S3 remote signing with FsspecFileIO:

1. LegacyOAuth2AuthManager.auth_header() returned the string "Bearer None"
   when no credential or initial_token was configured, instead of returning
   None. This caused S3V4RestSigner to forward an invalid Authorization header
   to the catalog signer endpoint, resulting in a 403 that propagated as
   SignError or was swallowed, leaving the S3 request unsigned.

   Fix: return None when self._token is None.

2. S3V4RestSigner was registered on the before-sign.s3 botocore event, but
   botocore short-circuits RequestSigner.sign() and returns early (without
   emitting before-sign) when signature_version=UNSIGNED is set. Since UNSIGNED
   is set alongside the signer to prevent botocore's own SigV4 from running,
   the S3V4RestSigner.__call__ was never invoked, and every S3 request went
   to the server completely unsigned, resulting in AccessDenied.

   Fix: register S3V4RestSigner on before-send.s3 instead of before-sign.s3.
   before-send fires unconditionally after signing (or after UNSIGNED's early
   return), giving the signer a chance to add catalog-signed headers before the
   HTTP request is dispatched. Update header assignment from add_header() to
   dict-style assignment, which is compatible with both AWSRequest (before-sign)
   and AWSPreparedRequest (before-send).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
auth_header() makes no HTTP requests, so checking request_history
against an unattached mock was both incorrect and unreachable.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ebyhr

ebyhr commented Jun 15, 2026

Copy link
Copy Markdown
Member

@abhishekkumar2024 thanks for your contribution! Could you please update the PR description so reviewers can understand the motivation?

@rambleraptor

Copy link
Copy Markdown
Collaborator

+1 on @ebyhr's comment. I'm not sure what this PR is trying to accomplish.

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.

3 participants