spring boot+React中的java会话超时
我能够在web中配置会话超时。xml,但在会话超时后从react端获取错误。 使用spring安全性和jwt令牌
网络安全。爪哇
@Configuration
@EnableWebSecurity
public class WebSecurity extends WebSecurityConfigurerAdapter {
@Autowired
UserDetailServiceImpl userDetails;
@Autowired
JWTAuthenticationFilter jwtRequestFilter;
@Autowired
public void configAuthentication(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetails).passwordEncoder(getPasswordEncoder());
}
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity.csrf().disable().authorizeRequests()
.antMatchers(HttpMethod.GET, "/index*", "/static/**", "/*.js", "/*.json", "/*.ico", "/*.png")
.permitAll().antMatchers("/resources/**", "/login", "/", "/actuator").permitAll()
.antMatchers("/authenticate/**", "/identity/**").permitAll().anyRequest().authenticated().and().cors().and()
.exceptionHandling().and().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
httpSecurity.addFilterBefore(jwtRequestFilter, UsernamePasswordAuthenticationFilter.class);
}
@Override
@Bean
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
网络。xml
<session-config>
<session-timeout>1</session-timeout>
</session-config>
我试过sessionManagement()。InvalidSessionURL(“url”)但在登录时,它总是只重定向到无效的url。 没有用于登录的api,我们直接从React加载。 请让我知道如何在会话超时时重定向到登录页面?如何从反应端处理错误
共 (0) 个答案