powered by simpleCommunicator - 2.0.59     © 2025 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Java [игнор отключен] [закрыт для гостей] / Spring Security - Filter for Url Pattern without Authentification?
1 сообщений из 1, страница 1 из 1
Spring Security - Filter for Url Pattern without Authentification?
    #39646582
_webdev_
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Здравствуйте.

Помогите немного с настройкой Spring Security, нашёл что-то похожее, то что надо, но оно как-то не очень у меня работает..
https://stackoverflow.com/a/36875726/1590594

Суть. В конфигурации указано, что каждый запрос должен быть аутентифицирован.
Нужно следующее, чтоб по указанному URL("/push") срабатывал только один фильтр, делал соотв проверку и или пропускал запрос дальше или отклонял. Без аутентификации.

Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.csrf().disable().
                sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
                .and().
                authorizeRequests()
                .anyRequest().authenticated().
                and().
                anonymous().disable().
                exceptionHandling().authenticationEntryPoint(unauthorizedEntryPoint());
        http.addFilterBefore(new UserAuthenticationFilter(authenticationManager()), BasicAuthenticationFilter.class);
        http.authorizeRequests().antMatchers(HttpMethod.POST, "/push").authenticated().and().addFilterBefore(new RPushFilter(),BasicAuthenticationFilter.class);
    }




Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
public class RPushFilter extends GenericFilterBean {
    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest httpRequest = (HttpServletRequest) request;
        HttpServletResponse httpResponse = (HttpServletResponse) response;

        //IF NOT httpResponse.sendError(HttpStatus.BAD_REQUEST.value(), "Access denied");

        chain.doFilter(request, response);
    }
}



Спасибо огромное!
...
Рейтинг: 0 / 0
1 сообщений из 1, страница 1 из 1
Форумы / Java [игнор отключен] [закрыт для гостей] / Spring Security - Filter for Url Pattern without Authentification?
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]