我无法找到 HttpServletRequest 中的 java.security.Principal 是如何创建的 - 谁负责?它是如何完成的?一定要保存在Session中吗?
它如何连接到 Spring Security?
对于使用 Principal 进行用户授权/认证的 Spring Security,是否有任何替代方案?
如何实现自己的用户授权/身份验证,以便 Principal 包含当前用户?
最佳答案
- 通常,Principal 对象在成功登录后放入 session 中。参见 documentation .
- Springs
Authentication
接口(interface)扩展Principal
接口(interface) - 或者您可以使用 Apache Shiro
- 实现自己的
UserDetailsService
,它将返回您的用户对象(它必须实现UserDetails 接口(interface))参见docs .
关于java.security.Principal - 在 HttpServletRequest 和 Spring Security 中创建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9824942/