尝试使用 JWT(JSON Web token )创建具有用户身份验证的应用程序。但是,当我开始配置 WebSecurityConfig.java 时,我遇到了下一个问题:
@Override
protected void configure(HttpSecurity http) throws Exception {
String[] permited = new String[security.getIgnored().size()];
security.getIgnored().toArray(permited);
http
.csrf().disable()
.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint).and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
.authorizeRequests()
.antMatchers("/api/authenticate").permitAll()
.antMatchers("/api/user").permitAll()
.antMatchers("/").permitAll()
.antMatchers("/favicon.ico").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginProcessingUrl("/api/authentication")
.successHandler(ajaxAuthenticationSuccessHandler)
.failureHandler(ajaxAuthenticationFailureHandler)
.usernameParameter("username")
.passwordParameter("password")
.and()
.logout()
.logoutUrl("/api/logout")
.logoutSuccessHandler(ajaxLogoutSuccessHandler)
.invalidateHttpSession(true)
.deleteCookies("JSESSIONID");
http.addFilterBefore(jwtAuthenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
http.headers().cacheControl();
}
它向我显示“无法解析方法 getIgnored()”。这只是此方法开始时的几个步骤。
我了解到 Spring 有 2 个同名的类:
所以我需要第二个类中的 getIgnored() 方法。请帮助我完成这个过程。我知道这可能是一个愚蠢的问题,但我感谢任何帮助。
顺便说一句,这就是我如何使用 @Autowired 注释定义“安全性”:
@Autowired
SecurityProperties security;
最佳答案
嗯,这不是两个不同的类,而是不同版本的相同。
getIgnored
方法已被删除,请参阅 Github commit
关于java - Spring boot 中的安全属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50349966/