hanker

Spring h2-console 접속 안될때 (403 Error) 본문

SPRING/SPRING-ERROR

Spring h2-console 접속 안될때 (403 Error)

hanker 2021. 4. 17. 17:13

h2-console을 사용하여 개발을 진행하던 중 Spring security를 적용하니 갑자기 h2-console이 적용이 안된다.

음..?

 

spring security를 적용하면서 h2-console/** 까지 막아버려서(?) 그렇다

 

설정파일에 h2-console을 허용 시켜보자

각자가 설정한 SecurityConfig 클래스를 보면

    @Override
    protected void configure(HttpSecurity http) throws Exception{
        http
            .authorizeRequests()
                .antMatchers("/","/**").access("permitAll")
                .antMatchers("/h2-console/**").permitAll() // 추가
            .and()
                .csrf() // 추가
                .ignoringAntMatchers("/h2-console/**").disable() // 추가
                .httpBasic();
    }

    
    // Security 무시하기 
    public void configure(WebSecurity web)throws Exception{
        web.ignoring().antMatchers("/h2-console/**");
    }

이렇게 설정을 완료하고 재실행하면 잘들어가진다.