Spring Log безопасности перенаправляет в root после входа в систему, я получаю ошибку 404 - PullRequest
0 голосов
/ 28 июня 2019

У меня есть приложение Spring Boot, которое использует функции безопасности. Моя проблема заключается в том, что после входа в систему пользователь перенаправляется в корень "/", и этот URI приводит к ошибке 404. Я запускаю приложение как autoexec.

Мой класс WebSecurityConfig имеет следующую конфигурацию входа в систему:

http
    .authorizeRequests()
            .antMatchers("/javax.faces.resource/**").permitAll()
            .antMatchers("/viewExpired*").permitAll()
            .anyRequest().authenticated()
            .and()
        .formLogin()
            .loginPage(<login-url>).permitAll()
            .loginProcessingUrl("/login")
            .failureUrl("/login.xhtml?error=true")
            .defaultSuccessUrl(<url-not-root>)
            .and()
        .sessionManagement().invalidSessionUrl("/viewExpired.xhtml")
        .and()
        .exceptionHandling().accessDeniedPage("/denied.xhtml");

Мой web.xml содержит этот блок файла приветствия:

<welcome-file-list>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>

И index.html это:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <!-- This url exists -->
    <meta http-equiv="REFRESH" content="0;url=pages/people/peopleList.xhtml">
</head>
</html>

Похоже, этот index.html не загружен, что мое приложение не распознает корневой URI (я записываю его как http://localhost:8090 и выдает 404).

Заранее спасибо.

1 Ответ

1 голос
/ 01 июля 2019

Чтобы всегда делать перенаправление, вам нужно позвонить:

.defaultSuccessUrl(<url-not-root>, true)

Из документов API:

T   defaultSuccessUrl(String defaultSuccessUrl)
Specifies where users will go after authenticating successfully if they have not visited 
a secured page prior to authenticating.

T   defaultSuccessUrl(String defaultSuccessUrl, boolean alwaysUse)
Specifies where users will go after authenticating successfully if they have not visited 
a secured page prior to authenticating or alwaysUse is true.
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...