Vaadin and HTTP response codes

Hello!
Vaadin adds a much needed application system on top of HTTP. They’re great cakes, and I would like to eat them both.

When a browser visits my main UI VaadinServlet, I have a servlet Filter which diverts the call to another VaadinServlet which displays a login screen and performs the login. This actually works very smoothly and means that the browser isn’t diverted between multiple URLs and the whole process looks quite slick. It looks something like:

    @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpSession session = ((HttpServletRequest) request).getSession();
        
        User user = (User) session.getAttribute(USER_ATTRIBUTE);
        if(user != null) {
            process(request, response, chain, user);
            return;
        }

        loginDispatcher.forward(request, response);
    }

Ideally my servlet would also tell the browser that authentication was required, via an HTTP response code. I’m interested to know whether anyone has pursued modifying the HTTP response codes with Vaadin, for any purpose - even sending 404s when views aren’t found, etc. I imagine it’d be tricky: The Vaadin code assumes ownership of setting the response and probably doesn’t play nicely with others, lots of requests go through this Servlet, isolating which requests to modify would be a challenege, etc?

Am I about to enter a nightmarish hell? Or is there some magic provision for communicating sensible response codes to the browser?
Best, Dan.