java-ee – 警告:JACC:对于URL模式xxx,除了以下方法之外的所有
在
javax.faces.webapp.FacesServlet 文档中,提到了,
我的应用程序确实不依赖于其他HTTP方法(GET和POST除外).因此,我正在尝试使用< http-method> (或< http-method-omission>)排除除GET和POST之外的所有方法. 在web.xml中,JAAS Servlet安全性约束配置如下. <security-constraint> <display-name>AdminConstraint</display-name> <web-resource-collection> <web-resource-name>ROLE_ADMIN</web-resource-name> <description/> <url-pattern>/admin_side/*</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <auth-constraint> <description/> <role-name>ROLE_ADMIN</role-name> </auth-constraint> <user-data-constraint> <description/> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint> <security-constraint> <display-name>UserConstraint</display-name> <web-resource-collection> <web-resource-name>ROLE_USER</web-resource-name> <description/> <url-pattern>/user_side/*</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <auth-constraint> <description/> <role-name>ROLE_USER</role-name> </auth-constraint> <user-data-constraint> <description/> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint> 使用这些元素, <http-method>GET</http-method> <http-method>POST</http-method> 我希望不允许所有其他HTTP方法. 但是,GlassFish Server 4.1会在服务器终端上记录以下警告.
这是什么意思? 而不是在所有< security-constraint>中完成它.元素,可以全局配置,以便它可以应用于应用程序中的所有资源,并且可以省略除GET和POST HTTP请求之外的所有资源,即全局应用于应用程序 – 可能通过使用更通用的专用URL模式,如/ *? 有一个例子here.
我发现强文中的最后一句令人困惑.这是否意味着使用GET请求,匿名用户也可以访问给定url-pattern中列出的资源,因为它意味着“安全约束不适用于http-method GET”? 解决方法
这意味着除了GET和POST之外的所有方法都被发现,意味着不受保护.每个人都可以使用PUT和HEAD等方法访问url pattern / user_side / *而无需身份验证. 要保护其他方法,请添加以下内容: <security-constraint> <web-resource-collection> <web-resource-name>protected</web-resource-name> <url-pattern>/user_side/*</url-pattern> <http-method-omission>GET</http-method-omission> <http-method-omission>POST</http-method-omission> </web-resource-collection> <auth-constraint/> </security-constraint> 如果您使用的是Servlet 3.1,也可以使用较短的标签: <deny-uncovered-http-methods/>
是的,这是可能的.您可以使用url-pattern /包含所有子文件夹.
你是对的,这意味着匿名用户可以使用GET方法访问给定的url-pattern.所有其他方法都受到保护. 也可以看看: > security-constraint url-pattern and the * character within web.xml (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |