7
如何禁用特定URL的Spring Security
我正在使用无状态弹簧安全性,但如果要注册,我想禁用弹簧安全性。我禁用了 antMatchers("/api/v1/signup").permitAll(). 但它不起作用,我在下面收到错误消息: message=An Authentication object was not found in the SecurityContext, type=org.springframework.security.authentication.AuthenticationCredentialsNotFoundException 我认为这意味着弹簧安全过滤器正在工作 我的网址顺序始终为“ / api / v1” 我的春季配置是 @Override protected void configure(HttpSecurity http) throws Exception { http. csrf().disable(). sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS). and(). authorizeRequests(). antMatchers("/api/v1/signup").permitAll(). anyRequest().authenticated(). and(). anonymous().disable(); http.addFilterBefore(new AuthenticationFilter(authenticationManager()), BasicAuthenticationFilter.class); } 我的身份验证过滤器是 @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain …