JAX-RS访问控制
有人可以为我提供一些有关 JAX-R Web 服务中的访问控制的指示吗? 例如,根据用户凭证、姓名或任何其他标准限制访问。 在sun手册中找不到任何有用的信息。
提前致谢, 阿迪尔
Can some one provide me some pointers about access control in JAX-Rs web services. e.g. limiting access on the basis of user credentials, or name or any other criteria. Could not find any useful information in the sun manuals.
Thanks in advance,
Adhir
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我个人使用 Spring security 来完成此任务。 Spring security 允许轻松使用各种身份验证和授权方案(例如,通过针对数据库或 LDAP 服务器检查 HTTP 请求中的基本/摘要标头)。 使用 JAX-RS 设置并不难,并且还有一个基于方面的漂亮权限系统,您可以在其中执行以下操作
这确保经过身份验证的用户必须位于ROLE_ADMIN组中或者是订单的所有者才能删除它。
配置完成后,您在 JAX-RS 资源中要做的就是处理来自 spring 的安全异常并采取适当的操作(fx. 通过抛出 WebApplicationException 作为此处描述)
I personally use Spring security to accomplish this. Spring security allows for easy use of various authentication and authorizations schemes (E.g. by checking the basic/digest headers from the HTTP request against a database or LDAP server). It's not to hard to set up with JAX-RS and also has a nifty aspect based rights system where you can do stuff like
which ensures that a authenticated user must either be in the ROLE_ADMIN group or be the owner of the order to be allowed to delete it.
When this is configured all you have to do in your JAX-RS resource is to handle the Security exception from spring and take the appropriate action (fx. by throwing a WebApplicationException as described here)
人们可以通过多种方法来实现这一目标,并且本网站上有许多关于该主题的精彩主题(请参阅保护 REST API/Web 服务的最佳实践)
我个人使用 OAuth 来完成此任务。 有关 OAuth 的更多信息,请参阅OAuth 初学者指南
There are many ways that people have accomplished this and there are a number of great threads on the topic on this site (see Best Practices for securing a REST API / web service)
I personally use OAuth to accomplish this task. For more information on OAuth check out Beginner’s Guide to OAuth