Skip to content

Commit 3312732

Browse files
committed
Allow health check endpoints to bypass authentication
1 parent 137b6c1 commit 3312732

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/tonic/auth.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ pub struct AuthMiddleware<S> {
1919
}
2020

2121
async fn check(auth_keys: Arc<AuthKeys>, mut req: Request) -> Result<Request, Status> {
22+
// Allow health check endpoints to bypass authentication
23+
let path = req.uri().path();
24+
if path == "/qdrant.Qdrant/HealthCheck" || path == "/grpc.health.v1.Health/Check" {
25+
// Set default full access for health check endpoints
26+
let access = Access::full("Health check endpoints have full access without authentication");
27+
let inference_token = crate::common::inference::InferenceToken(None);
28+
29+
req.extensions_mut().insert::<Access>(access);
30+
req.extensions_mut().insert(inference_token);
31+
32+
return Ok(req);
33+
}
34+
2235
let (access, inference_token) = auth_keys
2336
.validate_request(|key| req.headers().get(key).and_then(|val| val.to_str().ok()))
2437
.await

0 commit comments

Comments
 (0)