繁体   English   中英

春季安全手册登录

[英]spring security manual login

我正在使用Spring Security,并想手动登录我的用户。

我的控制器看起来像这样:

 @RequestMapping("/login")
    public String login() {
        Authentication authenticationResult = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken("user2", "password"));
        SecurityContextHolder.getContext().setAuthentication(authenticationResult);
        return "redirect:/";
}

我在文档中找到了进行此登录的示例。

http://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#what-is-authentication-in-spring-security

我只是想问这种方法是否存在任何弊端或安全问题?

编辑:如果有人可以将我指向默认的spring / login请求ist处理的类(&docs?),它也可能回答我的问题,因为我可以查看如何在内部实现Spring的登录过程

当我们需要在用户登录之前进行一些处理时,这是一种变通方法。实际的问题出在您执行以下操作时。 当然,这些不是问题:-)。

  1. 如果您使用的是spring记住我令牌或自定义身份验证提供程序。
  2. 在数据库中使用加密密码时。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM