Skip to content

Feat/flight sql bearer auth example #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 21, 2025

Conversation

backkem
Copy link
Collaborator

@backkem backkem commented May 21, 2025

To test Jules, I asked it to add a bearer auth example. With a bit of cleanup it works now.
It could probably be made more concise but it does serve as a decent illustration. Remaining list issue seems unrelated.

google-labs-jules bot and others added 2 commits May 21, 2025 08:11
This commit introduces a new example, `bearer_auth_flight_sql.rs`, demonstrating how to implement Bearer Token authentication in a DataFusion Flight SQL server.

The example includes:
- A tonic interceptor (`bearer_auth_interceptor`) for validating Bearer tokens from the "authorization" header.
- A `UserData` struct to store information extracted from valid tokens, which is then added to request extensions.
- A custom `SessionStateProvider` (`MySessionStateProvider`) that retrieves `UserData` from request extensions to create or customize the `SessionState`. This provider also registers a sample CSV table ("test") for querying.
- Server-side setup to integrate the interceptor and custom session provider.
- Client-side test cases in the `main` function that attempt `GetTables` Flight SQL calls with:
    - A valid token (expected to succeed).
    - An invalid token (expected to fail).
    - No token (expected to fail).
- Module-level documentation explaining the example's functionality and components.

This example serves as a guide for you if you are looking to implement request-level authentication and session customization in your Flight SQL services.
@backkem backkem merged commit 5901b8d into main May 21, 2025
12 of 14 checks passed
@backkem backkem deleted the feat/flight-sql-bearer-auth-example branch May 21, 2025 10:49
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