title: Configure SpringSecurity 4 with application.properties
body: <p>I'm trying to add HTTP basic authentication into my springboot microservice.</p>
  
  <p>When I use the "code" way described in Spring <a href="http://docs.spring.io/spring-security/site/docs/4.1.0.RELEASE/reference/htmlsingle/#spring-security-config-2" rel="nofollow noreferrer">doc</a> it works perfectly:</p>
  
  <pre><code>@RestController
  public class Ping
  {
      @GetMapping("/ping")
      public String ping()
      {
          return "pong";
      }
  }
  @EnableWebSecurity
  public class SecurityConfig extends WebSecurityConfigurerAdapter
  {
      @Autowired
      public void configureGlobal(AuthenticationManagerBuilder auth)
          throws Exception
      {
          auth.inMemoryAuthentication()
              .withUser("user").password("password")
              .roles("USER");
      }
  }
  </code></pre>
  
  <p>But, if I want to use the properties way it seems that it's not possible or I'm doing something wrong:</p>
  
  <pre><code>security.basic.enabled = true
  security.basic.path = /**
  security.basic.realm = Spring
  
  security.user.name = user
  security.user.password = xxx
  security.user.role = USER
  
  security.sessions = always
  </code></pre>
  
  <p>Using this solution, only the resource <code>http://localhost/env</code> is secured, and <code>/ping</code> is not. It is possible to use only <code>application.properties</code> to configure a "simple" basic authentication to all the resources?</p>