Skip to content

Drop the redundant OAuth2 branch from get_user and collect_request_tokens - #72889

Merged
vatsrahul1001 merged 1 commit into
apache:mainfrom
astronomer:drop-oauth2-scheme-redundant
Sep 11, 2026
Merged

vatsrahul1001 merged 1 commit into
apache:mainfrom
astronomer:drop-oauth2-scheme-redundant

Conversation

@pierrejeambrun

@pierrejeambrun pierrejeambrun commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #72649, and stacked on it.

HTTPBearer and OAuth2PasswordBearer both extract the same Authorization: Bearer <token> header. Declaring both as FastAPI dependencies produces the
same token string twice on every request, so:

Drop the runtime branch in both. oauth2_scheme stays declared as an unused
parameter on get_user and logout so the OpenAPI security spec is
unchanged
and /docs still renders the OAuth2 password login form — this
is purely a runtime dead-code cleanup, no user-facing surface changes.

Verified locally: regenerated OpenAPI spec is byte-identical to the one on
#72649's HEAD; 130 tests pass in test_security.py + test_auth.py; ruff
and mypy clean.

This PR is stacked on #72649 and should be merged after it.


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.7)

Generated-by: Claude Code (Opus 4.7) following the guidelines

@pierrejeambrun
pierrejeambrun force-pushed the drop-oauth2-scheme-redundant branch from d76a8c7 to 91099ef Compare September 10, 2026 14:35
@pierrejeambrun pierrejeambrun changed the title Drop the redundant OAuth2PasswordBearer scheme Drop the redundant OAuth2 branch from get_user and collect_request_tokens Sep 10, 2026
@vatsrahul1001 vatsrahul1001 added this to the Airflow 3.3.2 milestone Sep 11, 2026
…kens

`HTTPBearer` and `OAuth2PasswordBearer` both extract the same `Authorization:
Bearer` header, so declaring both as dependencies produces the same string
twice. `get_user` had a dead branch for the OAuth2 side (the bearer branch
above it always matched first), and `collect_request_tokens` deduped the
duplicate anyway.

Keep `oauth2_scheme` declared as an unused parameter so the OpenAPI security
spec is unchanged and ``/docs`` still renders the OAuth2 password login form.
Only the runtime dead code goes.
@pierrejeambrun
pierrejeambrun force-pushed the drop-oauth2-scheme-redundant branch from 91099ef to 3041653 Compare September 11, 2026 09:37
@vatsrahul1001 vatsrahul1001 added the type:bug-fix Changelog: Bug Fixes label Sep 11, 2026
@vatsrahul1001
vatsrahul1001 merged commit 677b4ab into apache:main Sep 11, 2026
79 checks passed
@vatsrahul1001
vatsrahul1001 deleted the drop-oauth2-scheme-redundant branch September 11, 2026 10:53
@github-actions

Copy link
Copy Markdown
Contributor

Backport successfully created: v3-3-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
✅ v3-3-test PR Link

vatsrahul1001 pushed a commit that referenced this pull request Sep 11, 2026
…t_request_tokens (#72889) (#72943)

`HTTPBearer` and `OAuth2PasswordBearer` both extract the same `Authorization:
Bearer` header, so declaring both as dependencies produces the same string
twice. `get_user` had a dead branch for the OAuth2 side (the bearer branch
above it always matched first), and `collect_request_tokens` deduped the
duplicate anyway.

Keep `oauth2_scheme` declared as an unused parameter so the OpenAPI security
spec is unchanged and ``/docs`` still renders the OAuth2 password login form.
Only the runtime dead code goes.
(cherry picked from commit 677b4ab)

Co-authored-by: Pierre Jeambrun <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants