我有OAuth2的春季启动应用程序。我想为匿名访问打开几个端点。我可以使用:
http
.authorizeRequests()
.antMatchers("/xyz/**").anonymous()
.and()
.authorizeRequests()
.anyRequest().authenticated();
但有没有办法更有选择性地做到这一点,并通过在那里放一些注释只打开特定的端点?我试过@PermitAll
但它仍然需要身份验证。
你可以使用antMatchers(“/ YOUR_ENDOINT / **”)。permitAll();