Skip to content

Commit fd23e36

Browse files
committed
upgrade cookie __Host- prefix to __Host-Http-
__Host-Http- is a new cookie prefix forcing HttpOnly in addition to the existing __Host- prefix requirements.
1 parent ce7a458 commit fd23e36

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/java/app/attestation/server/AttestationServer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ public void handlePost(final HttpExchange exchange) throws IOException, SQLiteEx
12981298

12991299
final Base64.Encoder encoder = Base64.getEncoder();
13001300
exchange.getResponseHeaders().set("Set-Cookie",
1301-
"__Host-session=%d|%s; HttpOnly; Secure; SameSite=Strict; Path=/; Max-Age=%d".formatted(
1301+
"__Host-Http-session=%d|%s; HttpOnly; Secure; SameSite=Strict; Path=/; Max-Age=%d".formatted(
13021302
session.sessionId, new String(encoder.encode(session.token)),
13031303
SESSION_LENGTH / 1000));
13041304
exchange.sendResponseHeaders(200, -1);
@@ -1382,14 +1382,14 @@ private static String getCookie(final HttpExchange exchange, final String key) {
13821382

13831383
private static void purgeSessionCookie(final HttpExchange exchange) {
13841384
exchange.getResponseHeaders().set("Set-Cookie",
1385-
"__Host-session=; HttpOnly; Secure; SameSite=Strict; Path=/; Max-Age=0");
1385+
"__Host-Http-session=; HttpOnly; Secure; SameSite=Strict; Path=/; Max-Age=0");
13861386
}
13871387

13881388
private record Account(long userId, String username, byte[] subscribeKey, int verifyInterval, int alertDelay) {}
13891389

13901390
private static Account verifySession(final HttpExchange exchange, final boolean end)
13911391
throws IOException, SQLiteException {
1392-
final String cookie = getCookie(exchange, "__Host-session");
1392+
final String cookie = getCookie(exchange, "__Host-Http-session");
13931393
if (cookie == null) {
13941394
exchange.sendResponseHeaders(403, -1);
13951395
return null;

0 commit comments

Comments
 (0)