title: antMatchers Spring Security pattern with changeable URL user ID
body: <p>I was looking for the answer for a long time but couldnt find anything productive</p>
  
  <p>In my rest service I keep some functionality under: /account/{id}/download and I would like to set the acces ROLE in SecurityConfig java file, that only ROLE_TOKENSAVED users can access this url</p>
  
  <p>How should the pattern look like, when {id} is changeable? </p>
  
  <p>I tried some regexp patterns, but nothing worked as I wanted, here are some of my attempts:</p>
  
  <pre><code>1. antMatchers("account/**/download").access(somerolehere)
  2. antMatchers("account/\\d/download").access(somerolehere)
  3. antMatchers("account/[\\d]/download").access(somerolehere)
  </code></pre>
  
  <p>thanks in advance for your anserwers :)</p>
  
  <p>edit:</p>
  
  <pre><code>    @Override
      protected void configure(HttpSecurity http) throws Exception {            
          http.authorizeRequests()
                  .antMatchers("/admin**").access("hasRole('ROLE_ADMIN')")
                  .antMatchers("/account*//**").access("hasRole('ROLE_USER') or hasRole('ROLE_ADMIN')")
                  .antMatchers("/account/\\d+/download").access("hasRole('ROLE_TOKENSAVED')")
                  .antMatchers("/user**").permitAll()
                  //othercode...
      }
  </code></pre>