[英]Can I use JAX-RS @RoleAllowed in the Rest API resource's method, if EJB is used
根據 JBoss 7.1 Enterprise Edition,如果 RESTful 服務使用 EJB,則不建議在 Resource 的方法中使用 @RolesAllowed。
如果應用程序使用 EJB,請不要激活基於角色的安全性。 EJB 容器將提供功能,而不是 RESTEasy。
參考: https ://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.1/html/developing_web_services_applications/developing_jax_rs_web_services#Enable_Role-Based_Security_RESTEasy_JAX-RS_Web_Service
我對上述說法感到困惑。 我的應用程序是由 JAX-RS 層和 EJB 層構建的。 我正在解析 SecurityContext isUserInRole(String role) 方法的實現中的角色。 我的 web.xml 是空的。 這是否意味着我不能在資源的方法上使用@RolesAllowed,因為我的 REST 服務在后台使用 EJB?
否,@RoleAllowed 不調用 SecurityContext isUserInRole(String role) 方法。
因此,創建基於 @Namebinding 注釋的過濾器來處理 SecurityContext isUserInRole(String role) 的權限是最好的方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.