DEV Community

Al-Karid
Al-Karid

Posted on • Edited on

Using H2-console with Spring Security

If you've used the H2 console in Spring Boot (with or without Vaadin) before enabling Spring Security, you might have noticed that adding Spring Security blocks access to your database console. To fix this, the easiest way is to override the configure(WebSecurity web) method. Be careful with the method signature, as there is also a configure(HttpSecurity http) method, which won't help with this issue.

To regain access to your H2 console, you would typically do the following:

@Override 
protected void configure(WebSecurity web) throws Exception {
    web
        .ignoring()
        .requestMatchers(new AntPathRequestMatcher("/h2-console/**"));
    super.configure(web);
}
Enter fullscreen mode Exit fullscreen mode

And that's all!

Top comments (0)

Image of AssemblyAI

Automatic Speech Recognition with AssemblyAI

Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.

Try the API

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay