我是 spring 的新手,我正在使用 spring 安全性开发 spring boot REST,目前我实现了 JWT 令牌。我有一些问题,但似乎无法找到答案。我尝试添加刷新令牌。
起初我以为我会将它与用户一起存储在数据库中,但是 Spring Security 会自动完成所有操作,而且我似乎无法找到如何将它存储在表用户的给定字段中。
所以,继续我决定我会尝试坚持使用 spring 安全自动化,我将刷新令牌过期时间设置为 10 秒来测试它是否过期,但遗憾的是它没有按预期工作 - 我可以使用刷新令牌,只要我想并用它生成新的令牌。
所以在这里我有几个问题:
1. 如何使刷新令牌在给定时间后过期?这是我的安全配置
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Value("${security.signing-key}")
private String signingKey;
@Value("${security.encoding-strength}")
private Integer encodingStrength;
@Value("${security.security-realm}")
private String securityRealm;
@Autowired
private UserDetailsService userDetailsService;
@Bean
@Override
protected AuthenticationManager authenticationManager() throws Exception {
return super.authenticationManager();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
}
@Bean
public PasswordEncoder passwordEncoder() {
PasswordEncoder encoder = …Run Code Online (Sandbox Code Playgroud) 因此,ChromeDriver版本再次升级到84版本,而我的chrome仍然是83版本,没有任何可用更新(可能是因为我将Linux Mint升级到20)。这会产生很好的旧结果:
session not created: This version of ChromeDriver only supports Chrome version 84
Run Code Online (Sandbox Code Playgroud)
我们已经知道如何解决这个问题,并且像往常一样,要运行 e2e 测试,我需要使用解决方法降级 ChromeDriver 版本:
"pree2e": "node ./node_modules/protractor/bin/webdriver-manager update --gecko=false --versions.chrome '83.0.4103.116-1'",
"e2e": "ng e2e --webdriver-update=false"
Run Code Online (Sandbox Code Playgroud)
然后运行npm run e2e让它工作。
有没有办法自动强制 ChromeDrive 匹配 Chrome 版本?就像编写一个pree2e脚本来检查当前的 chrome 版本然后强制ChromeDriver使用相同的版本一样?
selenium-chromedriver selenium-webdriver protractor e2e-testing angular