向已通过身份验证的用户添加新角色(无需将其注销)
我正在使用 Spring Security,在某些情况下,登录后用户可以执行一些操作,这应该使他能够访问某些资源,因此理想情况下应该通过为该用户提供新角色来完成。但是,org.springframework.security.core.userdetails.User类内部的权限是不可修改的。因此,给定的角色列表中不允许进行任何更改。 开发人员在这种情况下通常会做什么(我确信这是很常见的正常行为)?
I'm using Spring Security, and in some cases after logging in user can make some actions which should gave him access to some resources, so ideally it should be done via giving this user a new role. But, the authorities inside org.springframework.security.core.userdetails.User class are unmodifiable Set. So no any changes are allowed in the given list of roles.
How usually (I'm sure it's quite common, normal behaviour) developers do in this case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个有效的方法是审视你的角色并思考它们是否有意义。也许您需要拥有更多角色,以便用户可以在登录后立即执行所有操作。我认为你可能需要“将你的角色分解成更小的部分”。
登录后不允许修改角色。而你不应该这样做。这将对该平台构成安全威胁。
我以普通用户身份进行身份验证。执行一些代码并成为管理员。
这就是我认为你应该重新发出登录的原因。
乌多.
A valid approach would be to look at your roles and think if they make sense. Maybe you need to have more roles, so users are allowed to do everything right after login. I think you might need to "break in smaller pieces your roles".
You are not allowed to modified roles after logon. And you are not meant to do so. That would be a security threat to the platform.
I authenticate as a plain user. Execute some code and become admin.
That's what I think that you should reissue the login.
Udo.