Vaadin + Spring Security

I trying to follow this sample: https://vaadin.com/blog/-/blogs/a-hybrid-approach-to-spring-security-in-vaadin-applications

but when I try to use in my app in this method:

private static VaadinSession getSession() {
        VaadinSession session = VaadinSession.getCurrent();
        if (session == null) {
            session = new VaadinSession(VaadinService.getCurrent());
        }
        return session;
    }

my session always return null, I already try with @PreserveOnRefresh without, put in properties:
server.session.timeout=60
vaadin.servlet.close-idle-sessions=true
vaadin.servlet.heartbeat-interval=15

and my session still null.
And another doubt are, I have one view with my Login, so how I say that /#!Login are free for show?
tks

Where are you trying to use the getSession() method? The VaadinSession.getCurrent() works only when there is an active http request.

cheers,
matti