Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configured SameSite attribute to all OIDC session cookies #34073

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ public Uni<String> createTokenState(RoutingContext routingContext, OidcTenantCon
oidcConfig,
getAccessTokenCookieName(oidcConfig),
encryptToken(tokens.getAccessToken(), routingContext, oidcConfig),
routingContext.get(CodeAuthenticationMechanism.SESSION_MAX_AGE_PARAM));
routingContext.get(CodeAuthenticationMechanism.SESSION_MAX_AGE_PARAM), true);
if (tokens.getRefreshToken() != null) {
CodeAuthenticationMechanism.createCookie(routingContext,
oidcConfig,
getRefreshTokenCookieName(oidcConfig),
encryptToken(tokens.getRefreshToken(), routingContext, oidcConfig),
routingContext.get(CodeAuthenticationMechanism.SESSION_MAX_AGE_PARAM));
routingContext.get(CodeAuthenticationMechanism.SESSION_MAX_AGE_PARAM), true);
}
}
} else if (oidcConfig.tokenStateManager.strategy == OidcTenantConfig.TokenStateManager.Strategy.ID_REFRESH_TOKENS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ quarkus.oidc.tenant-split-tokens.credentials.secret=secret
quarkus.oidc.tenant-split-tokens.token-state-manager.split-tokens=true
quarkus.oidc.tenant-split-tokens.token-state-manager.encryption-secret=eUk1p7UB3nFiXZGUXi0uph1Y9p34YhBU
quarkus.oidc.tenant-split-tokens.application-type=web-app
quarkus.oidc.tenant-split-tokens.authentication.cookie-same-site=strict

quarkus.http.auth.permission.roles1.paths=/index.html
quarkus.http.auth.permission.roles1.policy=authenticated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -936,12 +936,15 @@ public void testDefaultSessionManagerSplitTokens() throws IOException, Interrupt

final String decryptSecret = "eUk1p7UB3nFiXZGUXi0uph1Y9p34YhBU";
Cookie idTokenCookie = getSessionCookie(page.getWebClient(), "tenant-split-tokens");
assertEquals("strict", idTokenCookie.getSameSite());
checkSingleTokenCookie(idTokenCookie, "ID", decryptSecret);

Cookie atTokenCookie = getSessionAtCookie(page.getWebClient(), "tenant-split-tokens");
assertEquals("strict", atTokenCookie.getSameSite());
checkSingleTokenCookie(atTokenCookie, "Bearer", decryptSecret);

Cookie rtTokenCookie = getSessionRtCookie(page.getWebClient(), "tenant-split-tokens");
assertEquals("strict", rtTokenCookie.getSameSite());
checkSingleTokenCookie(rtTokenCookie, "Refresh", decryptSecret);

// verify all the cookies are cleared after the session timeout
Expand Down Expand Up @@ -1023,11 +1026,6 @@ public Boolean call() throws Exception {
}
}

private void checkSingleTokenCookie(Cookie tokenCookie, String type) {
checkSingleTokenCookie(tokenCookie, type, null);

}

private void checkSingleTokenCookie(Cookie tokenCookie, String type, String decryptSecret) {
String[] cookieParts = tokenCookie.getValue().split("\\|");
assertEquals(1, cookieParts.length);
Expand Down