title: Spring boot with Spring Security j_spring_security_check not allowed
body: <p>My Spring Security Config</p>
  
  <pre><code>@Configuration
  @EnableWebSecurity
  @ComponentScan({"org.app.genesis.client.auth"})
  public class SecurityConfig extends WebSecurityConfigurerAdapter {
  
      @Autowired
      private AuthenticationProvider customAuthProvider;
  
      @Autowired
      public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
          auth.authenticationProvider(customAuthProvider);
      }
  
      @Override
      public void configure(HttpSecurity http) throws Exception {
          http.authorizeRequests()
              .and()
              .formLogin().loginPage("/").failureUrl("/?error")
              .and()
              .logout().logoutSuccessUrl("/?logout")
              .and()
              .csrf();
      }
  }
  </code></pre>
  
  <p>my application.properties</p>
  
  <pre><code>spring.view.prefix: /WEB-INF/jsp/
  spring.view.suffix: .jsp
  security.basic.enabled=false
  logging.level.org.springframework.security=INFO
  </code></pre>
  
  <p>my Spring boot configuration</p>
  
  <pre><code>@SpringBootApplication
  @ComponentScan({"org.app.genesis.client.controller","org.app.genesis.commons.service",
      "org.app.genesis.commons.security","org.app.genesis.inventory.service","org.app.genesis.client.auth"})
  @EnableJpaRepositories(basePackages = "org.app.genesis.*.repo")
  @EntityScan(basePackages = "org.app.genesis.*.model")
  public class Application extends SpringBootServletInitializer {
  
      public static void main(String[] args) {
          ApplicationContext ctx = SpringApplication.run(Application.class, args);
      }
  
      @Override
      protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
          return application.sources(Application.class);
      }
  
  }
  </code></pre>
  
  <p>A Gist of my pom.xml</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
      &lt;scope&gt;provided&lt;/scope&gt;
  &lt;/dependency&gt;
  &lt;!-- Spring Framework Dependencies --&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
  &lt;/dependency&gt;
  
  &lt;dependency&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-actuator&lt;/artifactId&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.apache.tomcat.embed&lt;/groupId&gt;
      &lt;artifactId&gt;tomcat-embed-jasper&lt;/artifactId&gt;
      &lt;scope&gt;provided&lt;/scope&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
      &lt;artifactId&gt;jstl&lt;/artifactId&gt;
      &lt;scope&gt;provided&lt;/scope&gt;
  &lt;/dependency&gt;
  
  &lt;dependency&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>The login form</p>
  
  <pre><code>&lt;form class="form-signin"name="f" action="${pageContext.request.contextPath}/j_spring_security_check" method="POST"&gt;
              &lt;fieldset&gt;
                      &lt;input class="form-control form-group" type="text" name="j_username" placeholder="Username"&gt;
                      &lt;input class="form-control" type="password" name="j_password" placeholder="Password" &gt;
                      &lt;a class="forgot pull-right" href="#"&gt;Forgot password?&lt;/a&gt;
                      &lt;button name="submit" class="btn btn-block btn-primary" type="submit"&gt;Sign in&lt;/button&gt;
              &lt;/fieldset&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>The controller that generates the page </p>
  
  <pre><code>@RequestMapping(value="/")
  public String index() {
      return "index";
  }
  </code></pre>
  
  <p>However upon logging in this error shows</p>
  
  <p><img src="https://i.stack.imgur.com/fvjPf.png" alt="enter image description here"></p>
  
  <p>I am trying to migrate my existing security.xml configuration on annotation. but however the said error pops up. here is my security.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans:beans xmlns="http://www.springframework.org/schema/security"
               xmlns:beans="http://www.springframework.org/schema/beans"
               xmlns:context="http://www.springframework.org/schema/context"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://www.springframework.org/schema/beans
             http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
             http://www.springframework.org/schema/security
             http://www.springframework.org/schema/security/spring-security.xsd
             http://www.springframework.org/schema/context
      http://www.springframework.org/schema/context/spring-context.xsd"&gt;
  
      &lt;context:component-scan base-package="org.brightworks.genesis.client.auth"/&gt;
  
      &lt;http pattern="/resources/**" security="none"/&gt;
      &lt;http pattern="/index.jsp" security="none"/&gt;
  
      &lt;http&gt;
          &lt;intercept-url pattern="/api/*" requires-channel="https"/&gt;
          &lt;!--TODO Add RESOURCE PATTERN checker --&gt;
          &lt;form-login login-page="/index.jsp" default-target-url="/dashboard"/&gt;
          &lt;logout /&gt;
      &lt;/http&gt;
  
      &lt;!-- Test Login values --&gt;
      &lt;authentication-manager&gt;
          &lt;!--use inMemoryUserDetailsService for faux auth --&gt;
          &lt;authentication-provider ref="customAuthenticationProvider"/&gt;
      &lt;/authentication-manager&gt;
  &lt;/beans:beans&gt;
  </code></pre>
  
  <p>Just in case you guys need to see the package structure</p>
  
  <p><img src="https://i.stack.imgur.com/Qy1md.png" alt="enter image description here">
  Have I missed anything in the configurations?</p>