2014-04-10 2 views
0

사용되지 않는 HTTP 메소드에 대한 액세스를 거부해야하는 경우가 있습니다.
우리는 JBoss 4.2에서 실행 중이며 로그인해야합니다. GET 및 POST를 제외한 다른 모든 액세스 시도는 거부되어야합니다.j2ee의 HTTP 메소드에 대한 액세스 거부

다음 web.xml 구성을 시도했지만 도움이되지 않습니다. 서블릿이 여전히 호출되어 예를 들어 반환됩니다. DELETE 요청시 "액세스가 거부되었습니다."
대신 501: Not implemented이 반환 될 것으로 예상됩니다.
첫 번째 보안 제약 조건에 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> 

어떻게해야하는지에 대한 아이디어가 있습니까?

답변

0

다른 가능성과 우편 배달부를 가지고 노는 것은 첫 번째 보안 제한이 블랙리스트라는 것을 알았습니다. 여기에 추가 된 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> 
관련 문제