Skip to content

Commit

Permalink
Include LinkedDataHub.id_token cookie value in the VCL hash, if it …
Browse files Browse the repository at this point in the history
…exists
  • Loading branch information
namedgraph committed Nov 22, 2024
1 parent 6f09257 commit 0e9c444
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions platform/varnish.vcl.template
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ sub vcl_recv {
set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", "");
set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", "");

if (req.http.Cookie ~ "LinkedDataHub\.id_token=") {
# Extract the LinkedDataHub.id_token value
set req.http.X-LinkedDataHub-Id-Token = regsub(req.http.Cookie, ".*LinkedDataHub\.id_token=([^; ]+).*", "\1");
}

if (req.http.cookie ~ "^\s*$") {
unset req.http.cookie;
}
Expand All @@ -70,10 +75,16 @@ sub vcl_hash {
hash_data(req.url);
hash_data(req.http.Host);

# include the client certificate in the hash, if it exists
if (req.http.Client-Cert) {
hash_data(req.http.Client-Cert);
}

# include LinkedDataHub.id_token cookie value in the hash, if it exists
if (req.http.X-LinkedDataHub-Id-Token) {
hash_data(req.http.X-LinkedDataHub-Id-Token);
}

return (lookup);
}

Expand Down

0 comments on commit 0e9c444

Please sign in to comment.