Jakarta ee 拒绝j2ee中HTTP方法的访问
我遇到了需要拒绝访问未使用的HTTP方法的情况。Jakarta ee 拒绝j2ee中HTTP方法的访问,jakarta-ee,configuration,jboss,Jakarta Ee,Configuration,Jboss,我遇到了需要拒绝访问未使用的HTTP方法的情况。 我们在JBoss4.2上运行,需要登录。除get和POST外,应拒绝所有其他访问尝试 我尝试了web.xml的以下配置,但没有帮助。servlet仍被调用,并在删除请求时返回“拒绝访问”等信息。 相反,我希望返回一个501:notimplemented。 如果我在第一个安全约束中不包含任何HTTP方法,用户将立即获得未经授权的页面 <web-app> <security-constraint> &l
我们在JBoss4.2上运行,需要登录。除get和POST外,应拒绝所有其他访问尝试 我尝试了web.xml的以下配置,但没有帮助。servlet仍被调用,并在删除请求时返回“拒绝访问”等信息。
相反,我希望返回一个
501:notimplemented
。如果我在第一个安全约束中不包含任何HTTP方法,用户将立即获得未经授权的页面
<web-app>
<security-constraint>
<web-resource-collection>
<web-resource-name>Deny most when not logged in</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<!-- no auth-constraint tag here -->
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>Allow methods</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>Admin</role-name>
</auth-constraint>
</security-constraint>
</web-app>
未登录时拒绝most
/*
得到
邮递
允许方法
/*
得到
邮递
放
管理
关于如何做到这一点有什么想法吗?玩弄各种可能性和邮递员,我发现第一个安全约束是黑名单。这里添加的http方法被拒绝,JBoss返回403。
因此,第一个安全约束现在如下所示:
<security-constraint>
<web-resource-collection>
<web-resource-name>Deny most when not logged in</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>PUT</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint/>
</security-constraint>
未登录时拒绝most
/*
放
删除