0
我有了這個安全配置:春季安全使用濾鏡permitAll不工作
@Override
public void configure(HttpSecurity http) throws Exception {
http
.addFilterBefore(
new JwtLoginFilter("/login", authenticationManager()),
UsernamePasswordAuthenticationFilter.class)
.addFilterBefore(
new JwtAuthenticationFilter(),
UsernamePasswordAuthenticationFilter.class);
http.csrf().disable()
.authorizeRequests().antMatchers("/", "/register").permitAll()
.and()
.authorizeRequests().anyRequest().authenticated();
}
兩個過濾器正在做認證工作。 authenticationFilter檢查auth cookie。
然而,permitAll不讓根路線和「/註冊」路線通行證(亦稱通過authenticationFilter,我認爲permitAll會讓這些路由信息通過過濾器仍然會)
有什麼不對?
我知道我可以使用webSecurity.ignoring來解決這個問題,但爲什麼上面的代碼不起作用? –