Skip to content

@W-23493263 Add JWT Bearer authentication to Arrow Flight - #665

Merged
jakeichikawasalesforce merged 10 commits into
masterfrom
w-23493263-arrow-flight-jwt-middleware
Aug 19, 2026
Merged

@W-23493263 Add JWT Bearer authentication to Arrow Flight#665
jakeichikawasalesforce merged 10 commits into
masterfrom
w-23493263-arrow-flight-jwt-middleware

Conversation

@jakeichikawasalesforce

@jakeichikawasalesforce jakeichikawasalesforce commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds JWT Bearer authentication to TabPy's Arrow Flight (gRPC) path so OAuth-configured clients can use Flight. Companion to #664, which covers HTTP JWT authentication.

  • Adds JwtAuthServerMiddlewareFactory, reusing jwt_auth.validate_jwt; failures surface as gRPC UNAUTHENTICATED.
  • Registers the JWT factory when OAuth is enabled and delegates Basic credentials through it when a password file is configured.
  • Keeps the Basic-only Flight path when OAuth is disabled and allows OAuth-only Arrow startup.
  • Makes Flight Basic usernames case-insensitive, matching the HTTP authentication path.
  • Accepts Basic-issued opaque Bearer tokens until its one-hour expiry or server restart. TabPy normally retains one token per username and permits a bounded two-token overlap during near-expiry rotation so existing clients are not disconnected.
  • Single-flights cold and expired JWKS fetches per URI while warm cached-key validation remains nonblocking.
  • Coordinates forced refreshes so concurrent requests for the same newly rotated kid share the result, while other unknown kids fail without starting additional fetches.
  • Keeps unknown-kid matching and cooldown publication atomic and rate-limits repeated failed refreshes for 30 seconds.
  • Rejects conflicting Flight Authorization values while accepting repeated copies of the same value.
  • Documents Flight transport security, authentication behavior, JWKS caching, opaque-token lifetime, and revocation limitations.

Testing

  • python -m pytest tests/unit -q: 196 passed
  • Arrow integration suites: 6 passed
  • Authentication-focused unit suites: 68 passed
  • Real FlightClient transport coverage for valid JWTs, invalid JWTs, and required scopes: 3 passed
  • flake8 on all changed Python files: passed
  • Deterministic concurrency coverage for cold and expired single-flight fetches, same-kid refresh sharing, atomic cooldown publication, cooldown-expiry recovery, and warm-cache nonblocking behavior
  • Independent review findings addressed; no known blockers

GUS: W-23493263

Without it Tornado treats the 2MB body as form-urlencoded and newer
Python parse_qsl rejects it with 400 before TabPy's 413 check runs.
Keep util.py unchanged so the pre-existing PBKDF2 hash stays out of
this diff. Flight header parsing now lives in flight_headers.py.
@jakeichikawasalesforce
jakeichikawasalesforce marked this pull request as ready for review August 18, 2026 21:09
Hold a per-URI fetch lock only around forced JWKS refreshes so a
forged unknown kid cannot reject valid HTTP or Flight tokens. Flight
still follows TABPY_TRANSFER_PROTOCOL, including http, matching the
existing HTTP Basic/Bearer cleartext behavior.
Keep unknown-kid cooldown publication under refresh ownership and preserve opaque Flight sessions without cross-user capacity eviction.
@jakeichikawasalesforce jakeichikawasalesforce changed the title Add JWT Bearer authentication to Arrow Flight @W-23493263 Add JWT Bearer authentication to Arrow Flight Aug 18, 2026
@jakeichikawasalesforce
jakeichikawasalesforce merged commit 56e9f3b into master Aug 19, 2026
23 checks passed
@jakeichikawasalesforce
jakeichikawasalesforce deleted the w-23493263-arrow-flight-jwt-middleware branch August 19, 2026 21:40
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.

2 participants