Skip to content

Commit

Permalink
fix extract_cookie function to handle grpc cookies in the header
Browse files Browse the repository at this point in the history
  • Loading branch information
Eshanatnight committed Apr 9, 2024
1 parent 91cce24 commit 486ecd1
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 486ecd1

Please sign in to comment.