Skip to content

Conversation

craig-rueda
Copy link
Contributor

Summary

This PR removes the authentication requirement for gRPC health check endpoints, allowing them to be accessed without API keys or JWT tokens. This change enables proper health monitoring and load balancer checks in production environments where authentication credentials may not be available or appropriate (we're using ALB's in AWS and can't really add keys)

Changes Made

Modified Files

  • src/tonic/auth.rs: Updated the authentication middleware to bypass validation for health check endpoints

Implementation Details

  • Added path-based routing logic in the check() function to identify health check requests
  • Health check endpoints now bypass the standard auth_keys.validate_request() flow
  • Endpoints are granted full access with appropriate Access and InferenceToken extensions
  • Early return prevents unnecessary authentication processing for these endpoints

Affected Endpoints

The following gRPC endpoints now work without authentication:

  1. Qdrant-specific health check: /qdrant.Qdrant/HealthCheck
  2. Standard gRPC health protocol: /grpc.health.v1.Health/Check

Testing

To test these changes:

# Build and run Qdrant locally
cargo build --release --bin qdrant
./target/release/qdrant

# Test health check endpoints without authentication
grpcurl -plaintext localhost:6334 qdrant.Qdrant/HealthCheck
grpcurl -plaintext localhost:6334 grpc.health.v1.Health/Check

# Verify other endpoints still require authentication
grpcurl -plaintext localhost:6334 qdrant.Collections/List  # Should fail without auth

Copy link
Contributor

coderabbitai bot commented Jul 23, 2025

📝 Walkthrough

Walkthrough

The check async function in src/tonic/auth.rs was updated to allow requests targeting specific health check endpoints (/qdrant.Qdrant/HealthCheck and /grpc.health.v1.Health/Check) to bypass the usual authentication process. For these endpoints, the function now inserts full access permissions and a default inference token into the request extensions without performing standard authentication. For all other endpoints, the existing authentication logic remains unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Note

⚡️ Unit Test Generation - Beta

CodeRabbit's unit test generation is now available in Beta! Automatically generate comprehensive unit tests for your code changes, ensuring better test coverage and catching edge cases you might miss. Our AI analyzes your code structure and creates tests that follow best practices and your project's testing patterns. Learn more here, or just try it under ✨ Finishing Touches.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/tonic/auth.rs (2)

22-33: Authentication bypass implementation looks secure and correct.

The implementation properly restricts the bypass to specific health check endpoints and follows the same extension pattern as authenticated requests. The full access grant is appropriate for health monitoring operations.

Consider adding audit logging for bypassed requests to maintain security visibility:

 async fn check(auth_keys: Arc<AuthKeys>, mut req: Request) -> Result<Request, Status> {
     // Allow health check endpoints to bypass authentication
     let path = req.uri().path();
     if path == "/qdrant.Qdrant/HealthCheck" || path == "/grpc.health.v1.Health/Check" {
+        log::debug!("Bypassing authentication for health check endpoint: {}", path);
         // Set default full access for health check endpoints
         let access = Access::full("Health check endpoints have full access without authentication");

24-24: Consider making health check paths configurable.

The hardcoded endpoint paths work well for the current use case. For better maintainability, consider making these paths configurable through environment variables or configuration files if endpoint paths might change in the future.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 137b6c1 and 3312732.

📒 Files selected for processing (1)
  • src/tonic/auth.rs (1 hunks)
🔇 Additional comments (1)
src/tonic/auth.rs (1)

26-27: Health check endpoints bypass authentication as designed

Verified that in src/tonic/auth.rs the two gRPC paths (/qdrant.Qdrant/HealthCheck and /grpc.health.v1.Health/Check) are explicitly granted Access::full, and the corresponding handlers in src/tonic/mod.rs only return version info or serving status without touching protected resources. No RBAC restrictions are needed for these endpoints.

Copy link
Member

@generall generall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@craig-rueda
Copy link
Contributor Author

Thanks, @generall. Any idea when this will be merged / released?

@generall
Copy link
Member

Thanks, @generall. Any idea when this will be merged / released?

1.15.1

@generall generall merged commit 080735b into qdrant:master Jul 24, 2025
16 checks passed
@craig-rueda craig-rueda deleted the craig/health-check-auth branch July 24, 2025 15:05
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