-
Notifications
You must be signed in to change notification settings - Fork 99
feat: Always use the security context from VaadinSession when one is available #907
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
Conversation
…ble. This ensures that the security context is the expected (the one from the UI you run access() on) if you run UI.access from a request to another VaadinSession. Practical use case is e.g. sending a global 'refresh' event and the receipient updating the UI as a result. Fixes #906
c966948 to
b0cb13a
Compare
...pring-security-flow/src/main/java/com/vaadin/flow/spring/flowsecurity/views/Broadcaster.java
Show resolved
Hide resolved
.../test-spring-security-flow/src/test/java/com/vaadin/flow/spring/flowsecurity/AbstractIT.java
Show resolved
Hide resolved
...pring-security-flow/src/test/java/com/vaadin/flow/spring/flowsecurity/UIAccessContextIT.java
Show resolved
Hide resolved
.../src/main/java/com/vaadin/flow/spring/security/VaadinAwareSecurityContextHolderStrategy.java
Show resolved
Hide resolved
|
|
||
| import static java.util.Objects.requireNonNull; | ||
|
|
||
| public final class VaadinAwareSecurityContextHolderStrategy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javadoc is needed. Although this is internally used class, a couple of sentences describing that this implementation looks for the VaadinSession for security context and it provides the security context for UI.access() calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added javadoc
...pring-security-flow/src/main/java/com/vaadin/flow/spring/flowsecurity/views/Broadcaster.java
Outdated
Show resolved
Hide resolved
.../src/main/java/com/vaadin/flow/spring/security/VaadinAwareSecurityContextHolderStrategy.java
Outdated
Show resolved
Hide resolved
| balanceSpan.setId("balanceText"); | ||
| add(balanceSpan); | ||
| add(new Button("Apply for a loan", this::applyForLoan)); | ||
| add(new Button("Apply for a huge loan", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apply for a huge loan button is not used in a tests. Is it for demo only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it is for manual testing only. At least for now
mshabarov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add the javadoc and some missed headers, but otherwise it look good to me: VaadinSession is used to lookup the security context and this security context is available within UI::access calls, even if the same thread is used for broadcast UI updates, so the developer doesn't need to execute the update in a separate thread (if I understood this enhancement correctly).
Co-authored-by: Mikhail Shabarov <61410877+mshabarov@users.noreply.github.com>
a0f1184 to
8bf6e8a
Compare
|
SonarQube analysis reported 1 issue
|
|
This ticket/PR has been released with platform 22.0.0.alpha5 and is also targeting the upcoming stable 22.0.0 version. |
…available vaadin/spring#907 This ensures that the security context is the expected (the one from the UI you run access() on) if you run UI.access from a request to another VaadinSession. Practical use case is e.g. sending a global 'refresh' event and the recipient updating the UI as a result. Fixes: vaadin/spring#906
…available vaadin/spring#907 This ensures that the security context is the expected (the one from the UI you run access() on) if you run UI.access from a request to another VaadinSession. Practical use case is e.g. sending a global 'refresh' event and the recipient updating the UI as a result. Fixes: vaadin/spring#906


This ensures that the security context is the expected (the one from the UI you run access() on) if you run UI.access from a request to another VaadinSession.
Practical use case is e.g. sending a global 'refresh' event and the receipient updating the UI as a result.
Fixes #906