Код: Выделить всё
@GetMapping("/")
public String homePage() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if(authentication == null) return "home";
return "dashboard";
}
Кроме того, я знаю, что могу переопределить метод configure(HttpSecurity http) в WebSecurityConfigurerAdapter следующим образом:
Код: Выделить всё
http.authorizeRequests().antMatchers("/").authenticated();
Это значение аутентификации после Sysout: org.springframework.security.authentication.AnonymousAuthenticationToken@52132976: Участник: анонимный пользователь; Учетные данные: [ЗАЩИЩЕНО]; Аутентифицировано: правда; Подробности: org.springframework.security.web.authentication.WebAuthenticationDetails@b364: RemoteIpAddress: 0:0:0:0:0:0:0:1; Идентификатор сеанса: ноль; Предоставленные полномочия: ROLE_ANONYMOUS