title: spring security 4 custom login page
body: <p>I would like to create custom pure html/js login page in Spring Security.
  I use Spring Boot 1.2.5.RELEASE
  I defined an application and configuration:</p>
  
  <pre><code>@SpringBootApplication
  public class Application {
      public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      }
  }
  
  @Configuration
  @EnableWebSecurity
  @EnableWebMvcSecurity
  public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
      @Override
      protected void configure(AuthenticationManagerBuilder auth) throws Exception {
          auth.inMemoryAuthentication().withUser("a").password("a").roles("USER");
      }
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {
         http
              .csrf().disable() // DISABLED CSRF protection to make it easier !
              .authorizeRequests()
              .antMatchers("/", "/login.html").permit
              .anyRequest().authenticated()
              .and()
              .formLogin()
              .loginPage("/login.html")
              .permitAll()
              .and()
              .logout()
              .permitAll()
              .logoutUrl("/logout")
              .logoutSuccessUrl("/");
      }
  
      @Override
      @Bean
      public AuthenticationManager authenticationManagerBean() throws Exception {
          return super.authenticationManagerBean();
      }
  }
  </code></pre>
  
  <p>My login page looks like that (copied from default page!)</p>
  
  <pre><code>&lt;html&gt;&lt;head&gt;&lt;title&gt;Login Page&lt;/title&gt;&lt;/head&gt;&lt;body onload='document.f.username.focus();'&gt;
  &lt;h3&gt;Login with Username and Password&lt;/h3&gt;&lt;form name='f' action='/login' method='POST'&gt;
  &lt;table&gt;
  &lt;tr&gt;&lt;td&gt;User:&lt;/td&gt;&lt;td&gt;&lt;input type='text' name='username' value=''&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Password:&lt;/td&gt;&lt;td&gt;&lt;input type='password' name='password'/&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td colspan='2'&gt;&lt;input name="submit" type="submit" value="Login"/&gt;&lt;/td&gt;    &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/form&gt;&lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>But I still have: AUTHORIZATION_FAILURE</p>
  
  <p>Is it possible to create pute html login page (without jsp, thymeleaf, etc.) ?
  What do I do wrong in my code ?</p>