In my app I have a UserContext bean (@VaadinSessionScope) which contains some user-related data.
Originally I initialized this bean after login by retrieving the necessary data from a backend service.
Now I changed (due to company policy) my app: authentication happens in a 3rd party component which adds a specific header with a JWT token.
I have setup SpringSecurity and a filter takes care of validating the JWT etc. It would feel natural to have another filter which initializes my UserContext, but I cannot access this bean in a filter.
Another idea is to use a SessionInitListener, but it seems that the beans in VaadinSessionScope are not created yet at this point.
Any advice what would be the right place to initialize my UserContext?
Bonus question: after initialization of UserContext I want to automatically forward to a view based on user’s role. Where should I do that?