使用 Spring Security 登录时记录用户代理信息
我在应用程序中使用 Spring Security 和 LDAP,并且希望在用户登录时记录用户代理。但是,我无法访问权限填充器中的请求对象,因此无法从那里访问用户代理信息。
我还尝试在记录器 (log4j) 中设置模式,以便它通过放入 %X{user-agent} 来记录用户代理,但这也不起作用。
我想要做的就是在用户登录时记录用户代理信息。因此,如果 Spring 的安全框架中有一个方法,我可以重写该方法,该方法将能够访问登录对象上的请求,这将是理想的。
或者
如果我可以让 log4j 在写入日志时记录用户代理,那也很好。
I am using Spring Security with LDAP for an application and I want to log the user-agent when the user logs in. However, I cannot access the request object in the Authorities Populator so I cannot access the user-agent information from there.
I also tried setting the pattern in our logger (log4j) so it would log the user agent by putting in %X{user-agent}, but that didn't work either.
All I want to do is log the user agent information when the user logs in. So if there is a method in Spring's security framework I can override that will have access to the request on login object that would be ideal.
OR
If I can get log4j to record the user agent whenver an entry to the log is made, that would be fine as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
扩展AuthenticationDetailsSourceImpl:
在身份验证过滤器中设置:
Extend AuthenticationDetailsSourceImpl:
Set it in the authentication filter: