【问题标题】:EnableOAuth2Client deprecated [closed]EnableOAuth2Client 已弃用 [关闭]
【发布时间】:2020-03-27 09:30:46
【问题描述】:

目前,我正在使用 Spring Boot 2.2.5 版本。文档看起来不完整。 @EnableOAuth2Client@EnableOAuth2Sso.enter image description here 的替代品是什么

【问题讨论】:

    标签: java spring spring-boot spring-security-oauth2


    【解决方案1】:

    您可以通过 WebSecurityConfigurerAdapter 的 配置方法而不是注释来完成。

    1. EnableOAuth2Sso 现在是这样的:

      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http.authorizeRequests()
           .anyRequest().authenticated()
           .and()
           .oauth2Login(); // sso           
      }
      
    2. @EnableOAuth2Client 现在是这个(完整示例和配置选项,请参阅Spring's migration guide):

      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http
              .oauth2Client();
      }
      

    【讨论】:

    • 既然它在其类名中提到了“Web”,它是否能够仅保护 API 资源?没有用户界面。
    猜你喜欢
    • 1970-01-01
    • 2016-02-04
    • 2012-03-01
    • 1970-01-01
    • 2011-02-17
    • 2014-12-03
    • 1970-01-01
    • 2019-02-11
    • 2014-02-12
    相关资源
    最近更新 更多