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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay