title: Spring OAuth 2: public access to a resource
body: <p>How do I allow public access in an specific URL in a Spring Security OAuth-2 Rest application.</p>
  
  <p>I have all URLs started with <code>/rest/**</code> secured, but would like to make <code>/rest/about</code> public, so I would not require the user to authenticate to access it. I tried using <code>permitAll()</code> but it still requires the token in the request. This is my <code>HttpSecurity</code> configuration:</p>
  
  <pre><code>@Configuration
  @EnableResourceServer
  protected static class ResourceServerConfiguration extends
          ResourceServerConfigurerAdapter {
  
      @Override
      public void configure(ResourceServerSecurityConfigurer resources) {
          resources.resourceId(RESOURCE_ID);
      }
  
      @Override
      public void configure(HttpSecurity http) throws Exception {
          http
                  .authorizeRequests()
                  .antMatchers("/rest/about").permitAll()
                  .antMatchers("/rest/**").authenticated()
                  ;
      }
  }
  </code></pre>
  
  <p>A GET request to <code>/rest/about</code> still returns <code>401 Unauthorized - "error":"unauthorized","error_description":"Full authentication is required to access this resource"</code></p>