title: Serving static resources in spring security - Allow access to all files in '/resources/public'
body: <p>I can serve static resources perfectly fine with this setup however I have to define on a file by file basis the files which are allowed to be served.</p>
  
  <p>My current use case is anything located in the <code>/resources/public/</code> directory should have allowed access by clients.  </p>
  
  <p>i've tried the one liner <code>/resources/public/**</code> and <code>/public/**</code> that still doesn't allow access to all public resources i get 403's. So in my http configure i've started defining file extensions that are permitted, but i don't like that approach as there are lots of different extensions in my webapp.</p>
  
  <p><strong>My question is</strong> how can i allow access to all files in <code>/resources/public/</code> without having to define ant matchers for each file extension or am i just being petty?</p>
  
  <p>Spring <code>WebSecurityConfigurerAdapter</code> - edited as per jmw5598's answer.</p>
  
  <pre><code>    @Override
      public void configure(WebSecurity web) throws Exception {
             web
              .ignoring()
              .antMatchers("/resources/**");
      }
  
  
      @Override
      protected void configure(HttpSecurity http) {
  
              http
                  .authorizeRequests()
                          .authorizeRequests()
                  .antMatchers(
                      "/public/**",
                      "/.svg", "/.ico", "/.eot", "/.woff2",
                      "/.ttf", "/.woff", "/.html", "/.js",
                      "/.map", "/*.bundle.*",
                      "/index.html", "/", "/home", "/dashboard")
                  .permitAll()
                  .anyRequest().authenticated();
      }
  </code></pre>
  
  <p>Controller for serving web app:</p>
  
  <pre><code>@CrossOrigin(origins = "http://localhost:4200", maxAge = 3600)
  @Controller
  public class AngularWebAppController {
  
      @GetMapping(value = "/{path:[^\\.]*}")
      public String redirect() {
          return "forward:/";
      }
  
  }
  </code></pre>
  
  <p>My directory structure in <code>/resources</code></p>
  
  <p><a href="https://i.stack.imgur.com/wbBi3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wbBi3.png" alt="enter image description here"></a></p>
  
  <ul>
  <li>Added as requested by dur's comment.
  <a href="https://i.stack.imgur.com/3AElg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3AElg.png" alt="enter image description here"></a></li>
  </ul>