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

fix: fix role checking when using websocket push (#20679) (CP: 24.6) #20709

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

mcollovati
Copy link
Collaborator

When using PUSH with websocket transport, the atmosphere wrapped request can be a no-op implementation whose isUserInRole method alwasy returns false, causing, for example, wrong access checking during navigation. This change falls back to Spring Securty for role checking when PUSH transport is websocket.
It also fixes some tests in order to propagate the Spring Security context when starting Thread that perform UI operations.

References psi#123
Part of #11026

@mcollovati mcollovati force-pushed the cherry/cherrypick-20679-to-24.6 branch from 5591805 to 56f918e Compare December 13, 2024 16:21
Copy link

github-actions bot commented Dec 13, 2024

Test Results

1 159 files  ± 0  1 159 suites  ±0   1h 28m 29s ⏱️ - 3m 31s
7 556 tests + 1  7 502 ✅ + 1  54 💤 ±0  0 ❌ ±0 
7 857 runs   - 44  7 795 ✅  - 43  62 💤  - 1  0 ❌ ±0 

Results for commit a3b4050. ± Comparison against base commit 276ded1.

♻️ This comment has been updated with latest results.

Comment on lines 390 to 409
// Workaround for https://github.com/vaadin/flow-components/issues/3646
// The issue causes the upload test to be flaky
private void waitForUploads(UploadElement element, int maxSeconds) {
WebDriver.Timeouts timeouts = getDriver().manage().timeouts();
timeouts.scriptTimeout(Duration.ofSeconds(maxSeconds));

String script = """
var callback = arguments[arguments.length - 1];
var upload = arguments[0];
let intervalId;
intervalId = window.setInterval(function() {
var inProgress = upload.files.filter(function(file) { return file.uploading;}).length >0;
if (!inProgress) {
window.clearInterval(intervalId);
callback();
}
}, 500);
""";
getCommandExecutor().getDriver().executeAsyncScript(script, element);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this test change needed for the cherry pick or should it be its own pick for the upload test fix from #20642?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch! You're right. I forgot to pick 20642. I'll add the labels, then I'll rebase this one (and the other related picks)

When using PUSH with websocket transport, the atmosphere wrapped request
can be a no-op implementation whose isUserInRole method alwasy returns
false, causing, for example, wrong access checking during navigation.
This change falls back to Spring Securty for role checking when PUSH
transport is websocket.
It also fixes some tests in order to propagate the Spring Security context
when starting Thread that perform UI operations.

References psi#123
Part of #11026
@mcollovati mcollovati force-pushed the cherry/cherrypick-20679-to-24.6 branch from 56f918e to a3b4050 Compare December 16, 2024 07:26
Copy link

sonarcloud bot commented Dec 16, 2024

@mcollovati mcollovati merged commit 4b75f5b into 24.6 Dec 16, 2024
25 of 26 checks passed
@mcollovati mcollovati deleted the cherry/cherrypick-20679-to-24.6 branch December 16, 2024 07:53
@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Vaadin 24.6.0.

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.

3 participants