Skip to content

Commit

Permalink
fix extract_cookie function to handle grpc cookies in the header (#746)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eshanatnight authored Apr 9, 2024
1 parent 91cce24 commit 32fa2bc
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions server/src/handlers/livetail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,17 @@ fn extract_basic_auth(header: &MetadataMap) -> Option<Credentials> {
}

fn extract_cookie(header: &MetadataMap) -> Option<Cookie> {
let cookies = header
.get("Cookie")
.and_then(|value| value.to_str().ok())
.map(Cookie::split_parse)?;
// extract the cookie from the request
let cookies = header.get_all("cookie");
let cookies: Vec<_> = cookies
.iter()
.filter_map(|value| value.to_str().ok())
.flat_map(Cookie::split_parse)
.map(|value| value.unwrap())
.collect();

cookies
.flatten()
.into_iter()
.find(|cookie| cookie.name() == SESSION_COOKIE_NAME)
}

Expand Down

0 comments on commit 32fa2bc

Please sign in to comment.