springauthenticationspring-securityrestful-authentication

authorize request with wildcard preceding url in spring web security


I have a rest endpoint of the form

{pathvariable}/foo/

and I want to permit access to this url:

httpSecurity
     .authorizeRequests()
        // Allow following urls to be called without authentification
        .antMatchers("**/foo").permitAll()

What I tried above is not working. Can anybody help?


Solution

  • found it myself: http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/util/AntPathMatcher.html

    .antMatchers("/{pathvariable:[0-9A-Za-z]+}/comment")