Весенняя охрана.принципал = anonymousUser, тип = AUTHORIZATION_FAILURE - PullRequest
0 голосов
/ 23 февраля 2019

Я пытаюсь создать Аутентификацию для моего приложения Spring Boot.Но я не могу не избавиться от

 principal=anonymousUser, type=AUTHORIZATION_FAILURE, data={type=org.springframework.security.access.AccessDeniedException, message=Access is denied}]

Вот моя конфигурация безопасности ОБНОВЛЕНО

   @Autowired
UserDetailsService userDetailsService;


@Override
protected void configure(HttpSecurity http) throws Exception {
    http
            .csrf().disable()
            .authorizeRequests()
            .anyRequest().authenticated()
            .antMatchers("/**").hasRole("USER")
            .and()
            .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
            .and()
            .formLogin()
            .failureHandler(authenticationFailureHandler())
            .successHandler(authenticationSuccessHandler());

}


@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    auth.userDetailsService(userDetailsService);
}


@Bean
public AuthenticationFailureHandler authenticationFailureHandler() {
    return new SimpleUrlAuthenticationFailureHandler();
}


@Bean
public AuthenticationSuccessHandler authenticationSuccessHandler() {
    return new RedirectAuthenticationSuccessHandler("/status");
}

И журнал с процессом аутентификации ОБНОВЛЕН :

    01:16:37.563 [http-nio-8080-exec-3] INFO  r.t.dao.DataRepositoryDaoImpl - Dao layer -> getAuthUser with userName: testuser
01:16:37.576 [http-nio-8080-exec-3] INFO  r.t.security.CustomUserAuthImpl - ::: AUTH::: User testuser is exist. And is_enable 1
01:16:37.578 [http-nio-8080-exec-3] INFO  o.s.b.a.audit.listener.AuditListener - AuditEvent [timestamp=Sun Feb 24 01:16:37 2019, principal=testuser, type=AUTHENTICATION_SUCCESS, data={details=org.springframework.security.web.authentication.WebAuthenticationDetails@fffde5d4: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: 4893CD513771B4710AE33C9B19CF62D6}]
01:16:37.580 [http-nio-8080-exec-3] INFO  o.s.b.a.audit.listener.AuditListener - AuditEvent [timestamp=Sun Feb 24 01:16:37 2019, principal=testuser, type=AUTHENTICATION_SUCCESS, data={details=org.springframework.security.web.authentication.WebAuthenticationDetails@fffde5d4: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: 4893CD513771B4710AE33C9B19CF62D6}]
01:16:37.581 [http-nio-8080-exec-3] INFO  o.s.b.a.audit.listener.AuditListener - AuditEvent [timestamp=Sun Feb 24 01:16:37 2019, principal=testuser, type=AUTHENTICATION_SUCCESS, data={details=org.springframework.security.web.authentication.WebAuthenticationDetails@fffde5d4: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: 4893CD513771B4710AE33C9B19CF62D6}]
01:16:37.586 [http-nio-8080-exec-4] INFO  o.s.b.a.audit.listener.AuditListener - AuditEvent [timestamp=Sun Feb 24 01:16:37 2019, principal=anonymousUser, type=AUTHORIZATION_FAILURE, data={type=org.springframework.security.access.AccessDeniedException, message=Access is denied}]

Кто-нибудь знает, в чем может быть проблема?Когда я вхожу в журнал \ перехожу в форму входа, Spring Security перенаправляет меня обратно на страницу входа в систему, и в журналах я вижу сообщение AUTHORIZATION_FAILURE.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...