Я добавил фильтр для SSO: < /p>
Код: Выделить всё
@Override
protected void doFilterInternal(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse, final FilterChain filterChain) throws ServletException, IOException {
final boolean isNotConnected = userService.isConnected(userService.getCurrentUser());
String token = httpServletRequest.getParameter("token");
if (isNotConnected && StringUtils.isNotEmpty(token)) {
try {
final DecodedJWT jwt = verify(token);
String id = decodedJWT.getSubject();
helper.ssoLogin(httpServletRequest, httpServletResponse, id);
} catch (Exception e) {
// log exception
}
}
filterChain.doFilter(httpServletRequest, httpServletResponse);
}
< /code>
В конце этого фильтра я успешно аутентифицирован. Однако, как только запрос пройдет через фильтры безопасности Spring, пользователь становится анонимным. Конец ssoconnectfilter:
Authentication [Principal=sso.test@stackoverflow.com, Credentials=[PROTECTED], Authenticated=true, Details=null, Granted Authorities=[ROLE_CUSTOMERGROUP]]< /code> < /p>
И вот результат после прохождения через Springsecurityfilterchain:
AnonymousAuthenticationToken [Principal=anonymous, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=C55080B50140AB87920815D195F4A3E1], Granted Authorities=[ROLE_ANONYMOUS]]Вот порядок моих фильтров:
< /code>
Когда я достигаю другого Filter и пытаюсь проверить пользователя, я обнаружил, что пользователь является анонимным. < /p>
Мое требование состоит Spring Security Filters, чтобы они могли получить доступ к страницам, которые требуют аутентификации. что пользователь остается аутентифицированным после фильтров безопасности Spring?
Подробнее здесь: https://stackoverflow.com/questions/793 ... -sso-in-hy
Мобильная версия