These 2 users have different authentication methods but they both generate jwt tokens, so to manage that i created 3 separate SecurityFilterChains through XML config, one for employees, one for Посетители и еще один для остальной части API, где аутентификация происходит через jwt токены, я еще не реализовал никакой авторизации и напрямую с настройкой Spring-Security . Отладка этой проблемы и выяснила, что аутентификация успешна с объектом аутентификации , созданного внутри SecurityContexTholder , но после этого запрос направлен в FilterChain - 3 AuthorizationFilter s, один для каждого SecurityFilterChain , Code>, что было успешно авторизовано. картирование/сотрудники/токен продолжает идти на следующую AuthorizationFilter , который имеет отображение/посетители/token и вот где он не выполняет авторизацию и бросает accessdeniedexception redireting to/error. Tomcat FilterChain содержит те же самые и те же 3 AuthorizationFilter в конце цепочки, плюс они также находятся в Spring FilterChainProxy в каждой DefaultsecurityFilterChain ниже мой setup. />[*]java version --> amazone corretto 17
[*]Spring boot version --> 3.5.3
[*]Security dependencies --> spring-boot-starter-oauth2-resource-server
security config:
Код: Выделить всё
< /code>
И это журнал, который я получаю во время запроса: < /p>
2025-08-21T22:20:10.704+01:00 WARN 28100 --- [vms] [nio-8080-exec-3] o.s.w.s.h.HandlerMappingIntrospector : Cache miss for REQUEST dispatch to '/vms/employees/token/' (previous null). Performing MatchableHandlerMapping lookup. This is logged once only at WARN level, and every time at TRACE.
2025-08-21T22:20:10.724+01:00 DEBUG 28100 --- [vms] [nio-8080-exec-3] o.s.security.web.FilterChainProxy : Securing POST /employees/token/
2025-08-21T22:20:10.756+01:00 DEBUG 28100 --- [vms] [nio-8080-exec-2] o.s.security.web.FilterChainProxy : Securing POST /employees/token
2025-08-21T22:20:11.153+01:00 DEBUG 28100 --- [vms] [nio-8080-exec-2] o.s.s.a.dao.DaoAuthenticationProvider : Authenticated user
2025-08-21T22:20:11.157+01:00 DEBUG 28100 --- [vms] [nio-8080-exec-2] o.s.s.w.a.www.BasicAuthenticationFilter : Set SecurityContextHolder to UsernamePasswordAuthenticationToken [Principal=Employee(username=admin, email=null, password=$2a$12$rhtf5U7jC39Isq8ZGa5zH.NnkQOb98glGkRDEFErIIW55FilRbWwm, position=null, profilePic=null, admin=true), Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=null], Granted Authorities=[admin, employee]]
2025-08-21T22:20:11.178+01:00 DEBUG 28100 --- [vms] [nio-8080-exec-2] o.s.security.web.FilterChainProxy : Secured POST /employees/token
2025-08-21T22:20:11.185+01:00 DEBUG 28100 --- [vms] [nio-8080-exec-2] o.s.security.web.FilterChainProxy : Securing POST /employees/token
2025-08-21T22:20:11.187+01:00 DEBUG 28100 --- [vms] [nio-8080-exec-2] o.s.security.web.FilterChainProxy : Secured POST /employees/token
2025-08-21T22:20:11.188+01:00 DEBUG 28100 --- [vms] [nio-8080-exec-2] o.s.s.w.access.AccessDeniedHandlerImpl : Responding with 403 status code
2025-08-21T22:20:11.209+01:00 DEBUG 28100 --- [vms] [nio-8080-exec-2] o.s.security.web.FilterChainProxy : Securing POST /error
2025-08-21T22:20:11.209+01:00 DEBUG 28100 --- [vms] [nio-8080-exec-2] o.s.security.web.FilterChainProxy : Secured POST /error
Подробнее здесь: https://stackoverflow.com/questions/797 ... pring-boot