繁体   English   中英

Spring Security将URL参数传递给Authentication Provider

[英]Spring Security pass URL parameters to Authentication Provider

有没有办法将URL参数传递给Spring Security 3中的身份验证提供程序?

我们的登录页面需要接收电子邮件令牌作为身份验证系统在设置用户状态时需要注意的参数。 具体来说,它将让用户具有正确的令牌登录,否则将无法登录。

我有一个自定义类扩展DaoAuthenticationProvider类。 我的身份验证逻辑在该类的authenticate方法中。

我希望有一些方法可以将这些数据传递给authenticate方法。

您可以在身份验证提供程序类上注入HttpServletRequest对象:

private @Autowired HttpServletRequest request;

现在,您应该能够使用API​​(例如request.getParameterValues(paramName)访问请求参数

您需要覆盖UsernamePasswordAuthenticationFilter.setDetails()并通过UsernamePasswordAuthenticationToken details属性将额外信息传递给您的自定义身份验证提供程序。

暂无
暂无

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

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