Невозможно войти в консоль H2 в весеннем приложении - PullRequest
0 голосов
/ 23 июня 2019

В моем весеннем приложении я добавил зависимость devtools.

Итак, я могу настроить консоль H2 следующим образом:

enter image description here

Я не делал никаких дополнительных настроек для H2. Так что я ожидаю, что кнопка «Подключить» позволит мне войти в БД. Но вместо этого я получаю:

enter image description here

Редактировать: безопасность пружины реализована как

protected void configure(HttpSecurity http) throws Exception {
    http
            .authorizeRequests()
                .antMatchers("/path1", "/path2")
                    .access("hasRole('ROLE_USER')")
                .antMatchers("/", "/**").access("permitAll")
            .and()
                .formLogin()
                    .loginPage("/login");//the path where custom login page will be provided
}

Что мне здесь не хватает?

1 Ответ

0 голосов
/ 23 июня 2019

На странице четко видно, что ошибка 403 (запрещено).Пожалуйста, проверьте ваши настройки безопасности.

Если вы используете Spring Security, проверьте класс конфигурации, который расширяет org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter, там в переопределенном методе:

  @Override
  protected void configure(HttpSecurity http) throws Exception {
    //super.configure(http);
    http
        .authorizeRequests()
        .antMatchers("/").permitAll() // you can allow the root endpoint ( also will be containing the default /h2-console endpoint ) for all users
                                      // or put some role restriction on the specific "/h2-console" endpoint to the admin user you are going to be logging in with.
        .antMatchers("/admin/**").hasRole("ADMIN")
          .and()
        .csrf().disable() //rest of the configs below according to your needs.
        .headers().frameOptions().disable()
          .and()
        .formLogin();
  }
...