Весенняя безопасность с Граалями
Я работаю над Spring Security с Grails. В моем сценарии мне нужно создать CustomAuthenticationFilter
где мне нужно поступить с некоторой логикой и вызвать поток безопасности весны.
Но я не могу назвать поток безопасности весны из структуры Грааля.
Следующие шаги приведены ниже:
- Создано
CustomAuthenticationFilter
- Создать токен с помощью
UsernamePasswordAuthenticationToken
и передатьAuthenticationManager
провайдеру это.token = this.getAuthenticationManager().authenticate(UsernamePasswordAuthenticationToken(username, password,authorities));
- Если нет
AuthenticationException
бросается тогда это означает успех и вернуть объект аутентификации. - Построить и вернуть объект аутентификации (
UsernamePasswordAuthenticationToken
) к фильтру, который будет помещен вSecurityContextHolder
,Code-SecurityContextHolder.getContext().setAuthentication(token);
- регистрирующий
CustomAuthenticationFilter
вBootStrap.groovy SpringSecurityUtils.clientRegisterFilter(customAuthenticationFilter, SecurityFilterPosition.SECURITY_CONTEXT_FILTER.order + 3)
регистрирующий
customAuthenticationFilter
вresources.groovy customAuthenticationFilter(CustomAuthenticationFilter) { authenticationManager = ref(‘authenticationManager’) }
Но на шаге 2 я получаю нулевые значения. Я не получаю токен. Я не знаю, где я допустил ошибку.