【发布时间】:2018-05-20 05:16:18
【问题描述】:
我正在处理 JWT 身份验证。我想绕过(不允许通过 jwt 过滤器)提供的 URL。下面是代码sn-p。
@Override
protected void configure(HttpSecurity http) throws Exception {
http.cors().and().csrf().disable().authorizeRequests().antMatchers(bypassURLs)
.permitAll().anyRequest().authenticated().and().addFilter(new JWTAuthenticationFilter(authenticationManager(), jwtConfigProperties))
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);}
在上面的代码中,我希望系统不要过滤bypassURLs。 如果我传递“/sayHello”,则不应将 JWTAuthenticationFilter 应用于此,而“/sayHello”以外的 URL 必须通过 JWTAuthenticationFilter。
我尝试了http.csrf().ignoringAntMatchers("/sayHello"); 和一些正则表达式,但没有成功。请帮忙。
【问题讨论】:
-
使用
.authorizeRequests().antMatchers("/sayHello").permitAll()。 -
我需要过滤除“/sayHello”之外的所有请求。