I have two paths:
/api/posts/{postId}
/api/posts/myPosts
I want to permit all for the first path and protect second path with role USER.
I tried below patterns but when I add first pattern, the second stop working (user can GET myPosts even if he doesn't have USER role). What I'm doing wrong?
.antMatchers(HttpMethod.GET, "/api/posts/{postId}").permitAll()
.antMatchers(HttpMethod.GET, "/api/posts/myPosts").hasRole("USER")