H2数据库显示带弹簧安全性的Spring-boot的空白页面(在线尝试解决方案)

时间:2018-01-17 01:51:00

标签: java spring-boot spring-security h2

我试过Why does the H2 console in Spring Boot show a blank screen after logging in?

我尝试添加http.headers().frameOptions().disable(); 还有

http.headers().frameOptions().sameOrigin();

我有以下配置。

auth:
  enabled: false
  serviceUrl: https://someURL/auth-service
  basicAuth: someEncryptedBasicAuth ANDDDDnnalsslasdkasmdlkadmlasd
  redirect: false

这是我的配置功能

@Override 
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers("/").permitAll().and()
    .authorizeRequests().antMatchers("/some-service/h2/**").permitAll()
    http.csrf().disable(); 
    http.headers().frameOptions().disable(); 
}

这是我在application.yml中的h2配置

# H2
spring:
  h2:
    console:
      enabled: true
      path: /h2
# Datasource
  datasource:
    url: jdbc:h2:file:~/test
    username: sa
    password:
    driver-class-name: org.h2.Driver

如您所见,我已尝试添加

一旦我使用用户名:sa和密码

登录h2 cosole

我得到一个包含网址的空白页:

  

http://localhost:8090/some-service/h2/login.do?jsessionid=someRandomString

这是我在IDE中获得的:

2018-01-16 17:45:07,144,Type=INFO,Category=ACCESS-LOGGER,Thread=http-nio-8090-exec-6,MDC=transaction_id=3476ce21-5273-41ee-a958-861a7a2d92d3, message_id=379d4e06-eaad-4cdf-a407-82f81c43139d,Text==== Request sent de972265-1232-45d5-8846-9674c26085f6 === 
2018-01-16 17:45:07,145,Type=INFO,Category=ACCESS-LOGGER,Thread=http-nio-8090-exec-6,MDC=transaction_id=3476ce21-5273-41ee-a958-861a7a2d92d3, message_id=379d4e06-eaad-4cdf-a407-82f81c43139d, message_type=null,Text==== Response received de972265-1232-45d5 -8846-9674c26085f6 ===

我在路径〜\

上有test.mv.db和test.trace.db

我需要做什么。如果您需要更多详细信息,请与我们联系。

编辑:

我在小提琴手中看到了回应。该页面将在登录后作为响应发送,该消息从未在浏览器上显示,而是出现空白窗口。

1 个答案:

答案 0 :(得分:0)

通过添加:

来实现它
    @Override
    public void configure(WebSecurity web) throws Exception {
        //super.configure(web);
        web.ignoring().antMatchers("**"); // everything is open until we lock it down (currently waiting on EU web)
    }