Add keycloak auth#214
Open
robinskil wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces optional Keycloak Bearer-JWT authentication for both HTTP (Axum) and Flight SQL transports, allowing for more robust and configurable authentication and authorization. The changes are backward-compatible: if Keycloak is not enabled in the configuration, the system continues to use legacy Basic authentication and anonymous access as before. When enabled, Keycloak authentication enforces role-based access control for both admin and query endpoints.
Keycloak Authentication Integration:
keycloakmodule (beacon-api/src/auth/keycloak.rs) that provides shared Keycloak JWT validation logic, builds admin and query layers based on configuration, and exposes claims for downstream authorization decisions.beacon-api/src/axum/router.rs) to build Keycloak layers at startup and pass them to the admin and client routers, enabling or disabling JWT validation as configured.beacon-api/src/axum/admin/mod.rs,beacon-api/src/axum/client/mod.rs) to accept optional Keycloak layers, applying them as middleware if present, or falling back to Basic/anonymous auth.Flight SQL Authentication Enhancements:
Extended the Flight SQL authenticator (
beacon-api/src/flight_sql/auth.rs) to support Keycloak JWT validation, including role-based admin/DDL privilege checks and correct handling of anonymous access based on configuration.Updated the Flight SQL service construction and tests to pass in Keycloak layers, ensuring consistent authentication logic across transports.
Dependency and Configuration Updates:
Added new dependencies for Keycloak and JWT validation (
axum-keycloak-auth,url) and updatedserde_jsonversion.Extended the main configuration struct to include Keycloak settings.
These changes provide a flexible, secure foundation for authentication and authorization, supporting both modern (Keycloak/JWT) and legacy (Basic/anonymous) modes as needed.