title: Spring Security using HTTP headers
body: <p>I am trying to add security to my Spring Boot application. My current application is using REST controllers and every time I get a <code>GET</code> or <code>POST</code> request I read the HTTP header to retrieve the user and password in order to validate them against the properties file I have all my users stored. I want to change this to using Spring Security and this is what I got so far:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class SecurityConfig extends WebSecurityConfigurerAdapter {
  
      @Bean
      protected void configure(HttpSecurity http) throws Exception {
          http.authorizeRequests()
              .antMatchers("/index.html").permitAll()
              .antMatchers("/swagger-ui.html").hasRole("ADMIN")
              .anyRequest().authenticated();
      }
  
      @Bean
      public UserDetailsService userDetailsService() {
          InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
          manager.createUser(User.withUsername("admin").password("password").roles("ADMIN").build());
      }
  }
  </code></pre>
  
  <p>How can I tell the <code>configure</code> method that the user credentials are to be retrieved from the header and not a login form?</p>