-
Notifications
You must be signed in to change notification settings - Fork 168
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's impersonation does not work on Vaadin #20495
Comments
This sounds to me more like an enhancement, however, we have to double check our integration with Spring Security, maybe there is something blocking this feature to work. |
Assuming the integration with Spring security is supposed to encompass all standard functionality, than this should be supported IMHO. |
@tbee JFYI, impersonation worked for me on V14 and V23, but I can't make it work on V24 too. |
I did a quick example project based on Vaadin 23 that uses Spring Security and First commit in this branch uses Next step is to rebase this to Vaadin 24 and figure out why we got an exception - random clues are major version jump of the Spring Security (Spring 5 -> Spring 6) or some new features in Vaadin 24 that added more logic to Spring Security integration. |
Hm, personally I'd probably prefer the solution with just a button. But it seems to be a lot of spring code of which I'm not certain how standard it is. Just redirecting to an URL is the approach with the lower coupling. |
It looks like |
What I found out was that with v24.6 the userFilter uses the wrong securityContextHolderStrategy. In short the changes are:
Impersonation of use
Exit impersonation
|
A possible solution could be modifying the
But would be good to figure out why the Vaadin context is not injected without this hack. |
The main issue is that when the Filter initializes the securitycontextholderstrategy gets chosen by default as Also it seems it's a timing issue from #14631 where the security context was moved from a set during configuration to being a Bean. Seems the correct fix for this would be to set up the userFilter as:
This way the context is correct when the switch user filter is generated. |
How about combining these two annotations together to embed this fix to the framework? (not tested though)
|
I would perhaps just go with documentation and an it test module in Flow so we catch any change to functionality on updates. |
Add to the security document documentation on the impersonation feature in Spring. Closes vaadin/flow#20495
Description of the bug
Spring offers a default way of an administrator impersonating a regular user. This seems not to work on Vaadin-on-Spring because Authorization seems not to be setup yet in the start-impersonating request. More here https://vaadin.com/forum/t/how-to-do-impersonation-using-spring-security/167804
Expected behavior
Well, it should work 😄
Minimal reproducible example
On a Vaadin-on-Spring application with Spring security and login enabled: configure the SwitchUserServlet as per one of the many examples, preferable on GET (which makes test easier) and attempt an impersonation. Probably VaadinAwareSecurityContextHolderStrategy should be set as the strategy on the filter (but won't fix the problem).
https://stackoverflow.com/questions/72378146/user-impersonation-with-spring-security
Versions
The text was updated successfully, but these errors were encountered: