Skip to content

Commit 7c6e027

Browse files
committed
Warn on large OIDC ID tokens
see #928
1 parent 740023d commit 7c6e027

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/webserver/oidc.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,13 @@ fn set_auth_cookie(
334334

335335
let id_token_str = id_token.to_string();
336336
log::trace!("Setting auth cookie: {SQLPAGE_AUTH_COOKIE_NAME}=\"{id_token_str}\"");
337+
let id_token_size_kb = id_token_str.len() / 1024;
338+
if id_token_size_kb > 4 {
339+
log::warn!(
340+
"The ID token cookie from the OIDC provider is {id_token_size_kb}kb. \
341+
Large cookies can cause performance issues and may be rejected by browsers or by reverse proxies."
342+
);
343+
}
337344
let cookie = Cookie::build(SQLPAGE_AUTH_COOKIE_NAME, id_token_str)
338345
.secure(true)
339346
.http_only(true)

0 commit comments

Comments
 (0)