title: Spring Security 4 - Allow Access To Controller And Authenticate Everything Else
body: <p>I was following this <a href="https://github.com/royclarkson/spring-rest-service-oauth" rel="nofollow">github project</a> to familiarize myself with Spring Security. I have the project up and running as is. I made a small modification to the OAuth2ServerConfiguration.java file trying to allow access to a controller and authenticating everything else. I'm not sure if it's possible to do this with 2 rules or not, here is the code in question:</p>
  
  <pre><code>    @Override
      public void configure(HttpSecurity http) throws Exception {
          // @formatter:off
          http
              .authorizeRequests()
              .antMatchers("/homecontroller").permitAll()
              .antMatchers("/greeting").authenticated();
          // @formatter:on
      }
  </code></pre>
  
  <p>The code above works fine, when I change <code>"/greeting"</code> to <code>/**</code>, everything requires authentication.</p>