Skip to content

Commit 50fef70

Browse files
graziangmposolda
authored andcommitted
Change cookie type for KC_AUTH_SESSION_HASH
Closes #38417 Signed-off-by: Giuseppe Graziano <[email protected]>
1 parent 6654e56 commit 50fef70

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

server-spi-private/src/main/java/org/keycloak/cookie/CookieType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public final class CookieType {
2020
.build();
2121

2222
public static final CookieType AUTH_SESSION_ID_HASH = CookieType.create("KC_AUTH_SESSION_HASH")
23-
.scope(CookieScope.INTERNAL_JS)
23+
.scope(CookieScope.FEDERATION_JS)
2424
.defaultMaxAge(60)
2525
.build();
2626

testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/cookies/DefaultCookieProviderTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public void testCookieDefaults() {
4444

4545
CookieProvider cookies = session.getProvider(CookieProvider.class);
4646
cookies.set(CookieType.AUTH_SESSION_ID, "my-auth-session-id");
47+
cookies.set(CookieType.AUTH_SESSION_ID_HASH, "my-kc-auth-session");
4748
cookies.set(CookieType.AUTH_RESTART, "my-auth-restart");
4849
cookies.set(CookieType.AUTH_DETACHED, "my-auth-detached", 222);
4950
cookies.set(CookieType.IDENTITY, "my-identity", 333);
@@ -52,8 +53,9 @@ public void testCookieDefaults() {
5253
cookies.set(CookieType.SESSION, "my-session", 444);
5354
cookies.set(CookieType.WELCOME_CSRF, "my-welcome-csrf");
5455
});
55-
Assert.assertEquals(8, response.getCookies().size());
56+
Assert.assertEquals(9, response.getCookies().size());
5657
assertCookie(response, "AUTH_SESSION_ID", "my-auth-session-id", "/auth/realms/master/", -1, true, true, "None", true);
58+
assertCookie(response, "KC_AUTH_SESSION_HASH", "my-kc-auth-session", "/auth/realms/master/", 60, true, false, "None", true);
5759
assertCookie(response, "KC_RESTART", "my-auth-restart", "/auth/realms/master/", -1, true, true, "None", false);
5860
assertCookie(response, "KC_STATE_CHECKER", "my-auth-detached", "/auth/realms/master/", 222, true, true, "Strict", false);
5961
assertCookie(response, "KEYCLOAK_IDENTITY", "my-identity", "/auth/realms/master/", 333, true, true, "None", true);
@@ -81,7 +83,7 @@ public void testCookieDefaultsWithInsecureContext() {
8183
});
8284
Assert.assertEquals(9, response.getCookies().size());
8385
assertCookie(response, "AUTH_SESSION_ID", "my-auth-session-id", "/auth/realms/master/", -1, false, true, "Lax", true);
84-
assertCookie(response, "KC_AUTH_SESSION_HASH", "my-kc-auth-session", "/auth/realms/master/", 60, false, false, "Strict", true);
86+
assertCookie(response, "KC_AUTH_SESSION_HASH", "my-kc-auth-session", "/auth/realms/master/", 60, false, false, "Lax", true);
8587
assertCookie(response, "KC_RESTART", "my-auth-restart", "/auth/realms/master/", -1, false, true, "Lax", false);
8688
assertCookie(response, "KC_STATE_CHECKER", "my-auth-detached", "/auth/realms/master/", 222, false, true, "Strict", false);
8789
assertCookie(response, "KEYCLOAK_IDENTITY", "my-identity", "/auth/realms/master/", 333, false, true, "Lax", true);
@@ -198,7 +200,7 @@ public void testSafariQuirks() {
198200

199201
Assert.assertEquals(9, response.getCookies().size());
200202
assertCookie(response, "AUTH_SESSION_ID", "my-auth-session-id", "/auth/realms/master/", -1, false, true, "Lax", true);
201-
assertCookie(response, "KC_AUTH_SESSION_HASH", "my-kc-auth-session", "/auth/realms/master/", 60, false, false, "Strict", true);
203+
assertCookie(response, "KC_AUTH_SESSION_HASH", "my-kc-auth-session", "/auth/realms/master/", 60, false, false, "Lax", true);
202204
assertCookie(response, "KC_RESTART", "my-auth-restart", "/auth/realms/master/", -1, false, true, "Lax", false);
203205
assertCookie(response, "KC_STATE_CHECKER", "my-auth-detached", "/auth/realms/master/", 222, false, true, "Strict", false);
204206
assertCookie(response, "KEYCLOAK_IDENTITY", "my-identity", "/auth/realms/master/", 333, false, true, "Lax", true);

0 commit comments

Comments
 (0)