Skip to content

Conversation

maryarm
Copy link
Contributor

@maryarm maryarm commented Aug 13, 2025

Description

When a user logs in, we determine their associations once (membership in roles, groups, tenants; application authorizations) and put them into the web session.

When these associations change (e.g. user is removed from a group; authorizations change), then this is not reflected in this cached state. Accordingly, as long as the user's session is alive, the changes do not take effect for them.

Related issues

closes #34698

@maryarm maryarm force-pushed the identity/34698-refresh-auth branch from 2c3e4b5 to 3f14e6a Compare August 13, 2025 07:52
@maryarm maryarm marked this pull request as draft August 13, 2025 09:27
@maryarm maryarm force-pushed the identity/34698-refresh-auth branch 3 times, most recently from 4b73713 to 2e71a01 Compare August 14, 2025 13:21
@maryarm maryarm marked this pull request as ready for review August 14, 2025 13:44
@maryarm maryarm force-pushed the identity/34698-refresh-auth branch from 3454292 to 4861e56 Compare August 14, 2025 14:20
@maryarm maryarm requested a review from a team as a code owner August 14, 2025 14:31
@maryarm maryarm requested review from npepinpe and bmudric and removed request for a team August 14, 2025 14:31
@npepinpe npepinpe removed their request for review August 14, 2025 15:02
Copy link
Contributor

@bmudric bmudric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just to check: do we need to document the new property authenticationRefreshInterval somewhere?

@maryarm maryarm added this pull request to the merge queue Aug 18, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 18, 2025
@maryarm maryarm added this pull request to the merge queue Aug 18, 2025
@cmur2 cmur2 removed this pull request from the merge queue due to a manual request Aug 18, 2025
@cmur2
Copy link
Member

cmur2 commented Aug 18, 2025

@maryarm please check CI error reasons before re-enqueing PRs into the merge queue! (via the View details button)

I see compilation errors for this PR in the merge: https://github.com/camunda/camunda/actions/runs/17033591357/job/48281074149

This can happen if there are newer changes on main and your PR is not rebased.

@maryarm maryarm force-pushed the identity/34698-refresh-auth branch from 2eaa31e to 09b9e5f Compare August 18, 2025 08:14
@maryarm maryarm added this pull request to the merge queue Aug 18, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 18, 2025
@maryarm maryarm added this pull request to the merge queue Aug 18, 2025
Merged via the queue into main with commit 8682001 Aug 18, 2025
165 of 168 checks passed
@maryarm maryarm deleted the identity/34698-refresh-auth branch August 18, 2025 11:28
Copy link
Member

@npepinpe npepinpe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice 🚀

try {
handleAuthenticationRefresh(request);
} catch (final Exception e) {
logger.debug("The session can't be refreshed.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Late to the party, but can we also make sure to add the exception as the last argument, so we can also see the error potentially causing this for debugging?


private static void initializeRefreshAttributes(final HttpSession session, final Instant now) {
session.setAttribute(LAST_REFRESH_ATTR, now);
session.setAttribute(LAST_REFRESH_ATTR + "_LOCK", new Object());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Cool, how does this work with the session storage? I'm 0% familiar with session storage in Spring - is it loaded once in-memory and reused, or is it possible that two threads load the session from the persistent store, and we get 2 different object references here?

}

@Test
void shouldOnlyRefreshOnceWhenMultipleConcurrentRequests() throws Exception {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 Does this actually do what we think? There is no guarantee we're actually testing the case where two requests are trying to refresh at the same time, is there? Am I missing something? I don't get how we're testing the refresh is truly synchronized 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Changes to application authorizations, groups, roles, and tenants take only effect after re-login
4 participants