gpt4 book ai didi

java - Spring-boot 安全记住我 token 不起作用

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:45:22 30 4
gpt4 key购买 nike

出于某种原因,我无法让 Spring-Security 与 remember-me 一起工作。它从不在客户端创建 cookie。

这是我的登录表单

<input type="checkbox" name="_spring_security_remember_me"/> Remember me

也试过

<input type="checkbox" name="remember-me"/> Remember me

这是我的安全设置

        http.authorizeRequests()
......
.anyRequest().fullyAuthenticated()
.and()
.formLogin().loginPage("/login").failureUrl("/login?error").permitAll()
.and()
.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout")).logoutSuccessUrl("/login")
.and()
.rememberMe()
.tokenValiditySeconds(31536000);

我尝试了我自己的自定义表单和内置的 Spring 登录表单。都无法记住我。

我测试的方法是,登录,复制安全网址,关闭浏览器,打开浏览器并粘贴网址。

最佳答案

这就像将 fullyAuthenticated() 更改为 authenticated() 一样简单。

正如在 fullyAuthenticated() 的 javadocs 中所说:

Specify that URLs are allowed by users who have authenticated and were not "remembered".

关于java - Spring-boot 安全记住我 token 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28111525/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com