title: How to create custom login with Vaadin4Spring MVP structure and Spring Security
body: <p>My current project is based on the structure of peholmst's vaadin4spring MVP:</p>
  
  <p><a href="https://github.com/peholmst/vaadin4spring/tree/master/samples/mvp-sample" rel="nofollow noreferrer">https://github.com/peholmst/vaadin4spring/tree/master/samples/mvp-sample</a></p>
  
  <p>Im using <strong>Vaadin 7.5.3</strong>, <strong>SpringBoot 1.2.5.RELEASE</strong> and <strong>JSR-330 1.0 (@Inject)</strong>.</p>
  
  <p>Now i want to create a new vaadin view login page in combination with spring security... My attempt was the following:</p>
  
  <p>HttpSecurityConfigurer.java</p>
  
  <pre><code>import org.springframework.context.ApplicationContext;
  import org.springframework.core.env.Environment;
  import org.springframework.security.config.annotation.web.builders.HttpSecurity;
  import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint;
  
  [...]
  
  void configure(Environment env, ApplicationContext appContext, HttpSecurity http) throws Exception {
     http
           .authorizeRequests()
               .antMatchers("/VAADIN/**", "/PUSH/**", "/UIDL/**", "/resources/**").permitAll()
               .anyRequest().authenticated()
               .and()
           .csrf().disable();
  
  
     http
           .formLogin()
               .loginPage("/login").defaultSuccessUrl("/", true).permitAll()
               .and()
           .logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout")).logoutSuccessUrl("/login").permitAll();
  }
  
  [...]
  </code></pre>
  
  <p>LoginUI.java</p>
  
  <pre><code>import javax.inject.Inject;
  
  import org.vaadin.spring.events.EventBus;
  
  import com.vaadin.annotations.Theme;
  import com.vaadin.annotations.Title;
  import com.vaadin.server.VaadinRequest;
  import com.vaadin.spring.annotation.SpringUI;
  import com.vaadin.ui.UI;
  
  import my.example.application.ui.presenter.Action;
  import my.example.application.ui.presenter.LoginPresenter;
  
  @SpringUI(path = "/login")
  @Theme("valo")
  @Title("MyLogin")
  public class MyLoginUI extends UI {
  
      private static final long serialVersionUID = -1746340376430847935L;
  
      @Inject
      LoginPresenter presenter;
  
      @Override
      protected void init(VaadinRequest vaadinRequest) {
          eventBus.publish(this, Action.START);
          setContent(presenter.getView());
      }
  
  }
  </code></pre>
  
  <p>LoginPresenter.java</p>
  
  <pre><code>import org.vaadin.spring.events.Event;
  import org.vaadin.spring.events.EventScope;
  import org.vaadin.spring.events.annotation.EventBusListenerMethod;
  import org.vaadin.spring.navigator.Presenter;
  import org.vaadin.spring.navigator.annotation.VaadinPresenter;
  
  import my.example.application.ui.view.LoginView;
  
  @VaadinPresenter(viewName = LoginView.NAME)
  public class LoginPresenter extends Presenter&lt;LoginView&gt; {
  
      @EventBusListenerMethod(scope = EventScope.SESSION, filter = StartupFilter.class)
      public void onStartup(Event&lt;Action&gt; event) {
          getView().setBody();
      }
  
  }
  </code></pre>
  
  <p>LoginView.java</p>
  
  <pre><code>import com.vaadin.spring.annotation.UIScope;
  import javax.annotation.PostConstruct;
  import com.vaadin.spring.annotation.SpringView;
  import com.vaadin.ui.VerticalLayout;
  import com.vaadin.navigator.View;
  [...]
  
  @UIScope
  @SpringView(name = LoginView.NAME, ui = MyLoginUI.class)
  public class LoginView extends VerticalLayout implements View {
  
      private static final long serialVersionUID = 8034398112492147989L;
  
      public static final String NAME = "loginView";
  
      @PostConstruct
      private void init() {
          setMargin(true);
          setSpacing(true);
          setSizeFull();
      }
  
      public void setBody() {
          addComponent(new Label("Heey, thats my login page! :)"));
      }
  
      @Override
      public void enter(ViewChangeEvent event) {
  
      }
  
  }
  </code></pre>
  
  <p>So when i start the application my browser redirects to "<a href="http://localhost:8080/login" rel="nofollow noreferrer">http://localhost:8080/login</a>" but its rendering only the vaadin loading animation:</p>
  
  <p><a href="https://i.stack.imgur.com/TCH5x.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TCH5x.png" alt="Vaadin loading animation"></a></p>
  
  <p>Can someone help me?</p>