Enabling Spring Boot Security – then disabling it

I added spring-boot-starter-security to my pom, but I’m trying to access the h2-console on localhost and it’s failing because I need to log in.

In my application.xml I have:

spring.security.user.name=user
spring.security.user.password=password

But I don’t want to type this in. How do I disable it? I created a new class in the root of my project and it seemed to work.

package com.example.demo;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter{
@Override
protected void configure(HttpSecurity http) throws Exception{
http.authorizeRequests().antMatchers("/").permitAll();
}
}

 

 

Leave a comment