我在我的项目中使用了spring security和Java配置。我们可以指定CSRF令牌到期超时吗?
缺省情况下,弹簧安全的Java配置启用了csrf。
是否可以设置超时之后csrf令牌过期?这是为基于令牌的应用程序指定超时的要求。
经过一些博客和文章后,我注意到csrf令牌的行为是不可预知的,使它更安全。
以下是用于配置弹簧安全性的示例代码。
@Override
protected void configure(HttpSecurity http) throws Exception {
http.sessionManagement().maximumSessions(1).expiredUrl("/login-expired.html").and().and()
.authorizeRequests().antMatchers("/superadmin/**").access("hasRole('ROLE_SUPER_ADMIN')").and()
.formLogin().loginPage("/signin.html").permitAll().failureUrl("/login-failed.html").permitAll()
.and().exceptionHandling().accessDeniedPage("/403").and().logout().permitAll().and()
.exceptionHandling().and().logout().logoutSuccessUrl("/logout.html").permitAll().and()
}
如果有某种方式可以设置超时时间,从而为我节省大量工作。