Skip to content

Commit ed9a7f8

Browse files
committed
chore: track that auth header is not empty
1 parent 587d0a1 commit ed9a7f8

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

packages/cubejs-backend-native/src/gateway/auth_middleware.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,20 @@ impl AuthExtension {
1919
fn parse_token(header_value: &HeaderValue) -> Result<&str, HttpError> {
2020
let trimmed = header_value.to_str()?.trim();
2121

22-
if let Some(stripped) = trimmed.strip_prefix("Bearer ") {
23-
Ok(stripped)
22+
let stripped = if let Some(stripped) = trimmed.strip_prefix("Bearer ") {
23+
stripped
2424
} else if let Some(stripped) = trimmed.strip_prefix("bearer ") {
25-
Ok(stripped)
25+
stripped
26+
} else {
27+
trimmed
28+
};
29+
30+
if stripped.is_empty() {
31+
Err(HttpError::unauthorized(
32+
"Value for authorization header cannot be empty".to_string(),
33+
))
2634
} else {
27-
Ok(trimmed)
35+
Ok(stripped)
2836
}
2937
}
3038

0 commit comments

Comments
 (0)