Bhavya Arora
Bhavya Arora

Reputation: 800

H2 Database showing blank page with Spring-boot with spring security(tried solutions online)

I have tried Why does the H2 console in Spring Boot show a blank screen after logging in?

I have tried adding the http.headers().frameOptions().disable(); and also the

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

I have the following configuration.

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

This is my configure function

@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(); 
}

this is my h2 config in application.yml

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

As you can see I have already tried adding

As soon as I login to the h2 cosole with username : sa and password :

I get a blank page with URL :

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

This is what I get in 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 ===

I have got test.mv.db and test.trace.db on the path ~\

What do I need to do. If you need any more details, let me know.

EDIT :

I saw the response in fiddler. The page is being sent as the response after logging in, which is never showed on the browser but instead a blank window is appearing.

Upvotes: 0

Views: 1448

Answers (1)

Bhavya Arora
Bhavya Arora

Reputation: 800

Got it working by adding :

    @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)
    }

Upvotes: 2

Related Questions