NokiaTube | New address | Mode Desktop | On high quality
Skip to content

Scope workflow state cleanup on user removal to the user's realm - #55602

Merged
pedroigor merged 2 commits into
keycloak:mainfrom
sguilhen:55470-workflow-cross-realm-state
Nov 27, 2026
Merged

pedroigor merged 2 commits into
keycloak:mainfrom
sguilhen:55470-workflow-cross-realm-state

Conversation

@sguilhen

Copy link
Copy Markdown
Contributor

Closes #55470

@sguilhen
sguilhen requested a review from a team as a code owner November 27, 2026 02:22
Copilot AI balanced review requested due to automatic review settings November 27, 2026 02:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Both new persistence regression tests lack @DatabaseTest, so they will not run in the cross-database suite.

1 open issue
What changed in this PR

This PR addresses #55470 by scoping per-resource workflow state operations to a realm, preventing user deletion from removing scheduled steps for resources with matching IDs in other realms.

Changes:

  • Adds realm IDs to workflow-state lookup and cleanup APIs and their callers.
  • Filters JPA queries through workflow components belonging to the specified realm.
  • Adds cross-realm collision regressions and updates existing workflow tests.
File Description
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​workflow/​WorkflowMigrationTest.java Updates scheduled-state assertions to include the realm.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​workflow/​WorkflowManagementTest.java Adds cross-realm cleanup and lookup regression tests.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​workflow/​step/​DeleteUserStepTest.java Uses realm-scoped lookups in user-deletion assertions.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​workflow/​execution/​WorkflowConcurrencyTest.java Uses realm-scoped lookups in concurrency assertions.
server-spi-private/​src/​main/​java/​org/​keycloak/​models/​workflow/​WorkflowStateProvider.java Adds and documents realm parameters for resource operations.
model/​jpa/​src/​main/​java/​org/​keycloak/​models/​workflow/​JpaWorkflowStateProviderFactory.java Passes the deleted user’s realm to cleanup.
model/​jpa/​src/​main/​java/​org/​keycloak/​models/​workflow/​JpaWorkflowStateProvider.java Restricts resource lookups and deletions by workflow realm.
model/​jpa/​src/​main/​java/​org/​keycloak/​models/​workflow/​DefaultWorkflowProvider.java Supplies the realm when retrieving scheduled state.

Review effort: Balanced

Closes keycloak#55470

- scope the delete to workflows owned by the user's realm, following the same approach used for removeAll()

Signed-off-by: Stefan Guilhen <[email protected]>
- same realm-isolation gap as the removeByResource fix, on the read side (getScheduledStepsByResource())

Signed-off-by: Stefan Guilhen <[email protected]>
@sguilhen
sguilhen force-pushed the 55470-workflow-cross-realm-state branch from 4337407 to 5e221cc Compare November 27, 2026 02:39
Copilot AI balanced review requested due to automatic review settings November 27, 2026 02:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the changes that isolate resource-based workflow state operations by realm.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@pedroigor
pedroigor merged commit f89c431 into keycloak:main Nov 27, 2026
97 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Workflow cleanup can delete scheduled state in another realm

4 participants