26

Struts2 アプリケーションに Tomcat を使用しています。には、次にweb.xml示すように特定のエントリがあります。

<security-constraint>
    <web-resource-collection>
        <web-resource-name>restricted methods</web-resource-name>
        <url-pattern>/*</url-pattern>
        <http-method>PUT</http-method>
        <http-method>DELETE</http-method>
        <http-method>TRACE</http-method>
    </web-resource-collection>
    <auth-constraint />
</security-constraint>
<security-constraint>
   <web-resource-collection>
       <web-resource-name>no_access</web-resource-name>
       <url-pattern>/jsp/*</url-pattern>
   </web-resource-collection>
   <auth-constraint/>
</security-constraint>
    <security-constraint>
   <web-resource-collection>
       <web-resource-name>no_access</web-resource-name>
       <url-pattern>/myrrunner/*</url-pattern>
   </web-resource-collection>
   <auth-constraint/>
</security-constraint>

ホワイトリストの部分のみを使用するようにブラックリストの部分を変更するにはどうすればよいですか...たとえば、ブラックリストPUTDELTEhttp メソッドの代わりに、他のメソッドをホワイトリストに登録する必要がありますが、それらをホワイトリストに登録する構文とそれらをホワイトリストに登録する方法がわかりません。

上記のweb.xmlスニペットについて、誰かが上記のカウンターパートをホワイトリストに登録してくれれば幸いですxml

編集:また、ソリューションが機能するかどうかを実際に確認するにはどうすればよいですか?

ありがとう

4

3 に答える 3

23

私は次のことを試します:

<security-constraint>
    <web-resource-collection>
        <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>restricted methods</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
   <auth-constraint/>
</security-constraint>

最初のメソッドにはsecurity-constraintがないauth-constraintため、GET および POST メソッドはログインなしで誰でも使用できます。2 つ目は、他の http メソッドをすべての人に制限します。(私はそれを試していません。)

于 2011-11-09T20:53:36.943 に答える