亚洲视频二区_亚洲欧洲日本天天堂在线观看_日韩一区二区在线观看_中文字幕不卡一区

公告:魔扣目錄網(wǎng)為廣大站長提供免費收錄網(wǎng)站服務,提交前請做好本站友鏈:【 網(wǎng)站目錄:http://www.430618.com 】, 免友鏈快審服務(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

本文介紹了為Spring Boot 2.0仿真器框架配置安全性的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想在我的Spring Boot 2.0應用程序中使用Spring Actuator框架。框架本身按照預期工作,因此我能夠到達例如我的/actuator/health終結(jié)點。在那里,我呈現(xiàn)了一個登錄對話框。我想擺脫它,并嘗試了以下方法:

@Configuration
@EnableWebFluxSecurity
public class SecurityConfiguration {

  @Bean
  public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {

    return http
               .authorizeExchange()
                   .matchers(EndpointRequest.to("prometheus")).permitAll()
                   .matchers(EndpointRequest.toAnyEndpoint()).authenticated()
                   .anyExchange().permitAll()
                   .and()
               .formLogin()
                  .and()
               .httpBasic()
                  .and()
               .build();
  }

但是,在應用程序啟動期間,我收到以下錯誤:

未能實例化[org.springframework.security.web.server.SecurityWebFilterChain]:工廠方法‘securityWebFilterChain’引發(fā)異常;嵌套異常為java.lang.IlLegalArgumentException:身份驗證管理器不能為空

當然,我試圖搜索它,但我總是只能得到描述使用Spring Boot 1.x框架的不同場景或安全配置的頁面。有人能幫我一下嗎?

推薦答案

最簡單的方法應該是讓SecurityConfiguration擴展WebSecurityConfigurerAdapter并覆蓋configure(WebSecurity web),如下所示:

public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

    @Override
    public void configure(WebSecurity web) throws Exception {
        web.ignoring()
                .antMatchers("/actuator/**");
    }

    // ...

}

另外,我不熟悉@EnableWebFluxSecurity,但要使上面的內(nèi)容正常工作,您需要同時使用@Configuration@EnableWebSecurity注釋。

至于設置配置的方式,它實際上并不是最優(yōu)的。為了補充上述建議,您應該使用HttpSecurity配置安全性,而不是使用當前的SecurityWebFilterChain

這篇關于為Spring Boot 2.0仿真器框架配置安全性的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,

分享到:
標簽:2.0 Boot Spring 仿真器 安全性 框架 配置
用戶無頭像

網(wǎng)友整理

注冊時間:

網(wǎng)站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨大挑戰(zhàn)2018-06-03

數(shù)獨一種數(shù)學游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學四六

運動步數(shù)有氧達人2018-06-03

記錄運動步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓練成績評定2018-06-03

通用課目體育訓練成績評定