-
Notifications
You must be signed in to change notification settings - Fork 176
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
Spring SecurityContext disappears in StreamResource callback method #5323
Comments
Hi @Julius95 , Can you verify the same project with JDK 1.8 for us? you can also fork this repository to make the sample project. https://github.com/vaadin/skeleton-starter-flow-spring |
Just tested with JDK 1.8.0_201 and problem still seems to exist. Tested on the newest bakery app. |
Okay I just tested with the skeleton project which you suggested and weirdly enough I can't reproduce the issue. It seemed that the skeleton project didn't have Spring Security as dependency but once I added it and tested it I got the expected behaviour. The issue can still be reproduced in bakery app though. Versions used in skeleton app:
|
Hi @Julius95 , if i understand correctly, even you add the Spring Security dependency, the app still works in an expected way (no bugs), right? |
Yeah, StreamResource callback method works as expected (no bugs) on skeleton project but the issue can be reproduced in the latest bakery app. Which implies something is wrong with Bakery app imo. |
I had the same issue: just remove @Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers(
// the standard favicon URI
"/favicon.ico",
// development-mode static resources
"/bower_components/**", "/icons/**", "/images/**", "/src/**",
"/manifest.json",
// webjars and frontend
"/webjars/**", "/frontend/**",
// production-mode static resources
"/build/**", "/frontend-es5/**", "/frontend-es6/**");
} |
Thank you @heruan for pointing out the problem. So bakery app comes with following WebSecurityConfiguration:
We can see that all "/VAADIN/" requests are ignored and won't have SpringSecurityContext. Dynamically created files are mapped to "VAADIN/dynamic/resource" url. When a request to dynamic resource is sent SpringSecurityContext is lost due to "/VAADIN/" configuration since the request url maps to it. To fix this remove "/VAADIN/" configuration or change it to "/VAADIN/static/**". This issue should be moved to bakery app since it contains this problematic configuration. |
Issue moved to vaadin/bakery-app-starter-flow-spring #755 via ZenHub |
Tested using the newest bakery app. Spring SecurityContext disappears and becomes Null authentication in StreamResource callback method. Below an example that reproduces the issue.
`@Route("test")
public class TestView extends VerticalLayout {
}`
Basically I created a simple view that contains only an Anchor element. When I click on the anchor
createInputStream
method is executed but Spring SecurityContext changes to null authentication.Expected behaviour: Spring SecurityContext should be the same during user session and not disappear like in
createInputStream
method.Actual behaviour: Spring SecurityContext disappears and changes to Null authentication.
As a side note I believe the Upload component's callback method
addSucceededListener
suffers from the same problem.The text was updated successfully, but these errors were encountered: