如何使用注释而不是HttpSecurity?

问题描述 投票:1回答:1

我有OAuth2的春季启动应用程序。我想为匿名访问打开几个端点。我可以使用:

http
    .authorizeRequests()
          .antMatchers("/xyz/**").anonymous()
          .and()
    .authorizeRequests()
          .anyRequest().authenticated();

但有没有办法更有选择性地做到这一点,并通过在那里放一些注释只打开特定的端点?我试过@PermitAll但它仍然需要身份验证。

java spring spring-boot spring-security spring-security-oauth2
1个回答
-1
投票

你可以使用antMatchers(“/ YOUR_ENDOINT / **”)。permitAll();

© www.soinside.com 2019 - 2024. All rights reserved.