Spring 是否筛选没有身份验证的Url模式?
请帮助我设置Spring 是否筛选没有身份验证的Url模式?,spring,spring-mvc,spring-boot,spring-security,Spring,Spring Mvc,Spring Boot,Spring Security,请帮助我设置Spring Security。 我发现了一些类似的东西,但不知怎么的,对我来说效果不太好。。 配置指定必须对每个请求进行身份验证。 必须执行以下操作,即在指定的URL(“/push”)上只使用一个筛选器。过滤器执行适当的检查,并进一步跳过请求或拒绝请求。没有身份验证 @Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable().
Spring Security
。
我发现了一些类似的东西,但不知怎么的,对我来说效果不太好。。
配置指定必须对每个请求进行身份验证。
必须执行以下操作,即在指定的URL(“/push”)上只使用一个筛选器。过滤器执行适当的检查,并进一步跳过请求或拒绝请求。没有身份验证
@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);
}
和过滤器
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);
}
}
真的无法理解您的问题,请您重新表述您的问题。我只需要一个筛选器(RPushFilter)来处理(“/push”)-Url。所有的过滤器都将被忽略。我未经授权。