Reputation: 115242
I need to provide certain role for accessing a URL in the following format:
/connector/{programId}/order/{anything here}
Where programId
is an integer value so I'd tried the following and it doesn't work at all.
.antMatchers('/connector/{programId:\\d+}/order/**').access("hasRole('CONNECTOR')")
But when I used **
instead of the programId
part it's working well. But how can I make it work with pathVariable (which is always an integer).
Upvotes: 1
Views: 4015
Reputation: 91
I am using:
.regexMatchers("/connector/(\\d+)/order/.*").access("hasRole('CONNECTOR')")
But server response 405 error
Upvotes: 1
Reputation: 2696
You should use RegexRequestMatcher
instead of AntPathRequestMatcher
.
.regexMatchers("/connector/(\\d+)/order/.*").access("hasRole('CONNECTOR')")
Upvotes: 6