Java Servlet 3.1 セキュリティー・サポートの構成
Liberty は、Java™ Servlet 3.1 仕様で定義されているすべてのセキュリティー更新をサポートします。
このタスクについて
Libertyで Java Servlet 3.1 フィーチャーを利用します。
手順
-
server.xmlファイルにservlet-3.1フィーチャーを追加します。<feature>servlet-3.1</feature> - 以下のどの Java Servlet 3.1 機能を使用するかを決定します。
- ログイン・フォームに autocomplete=off を指定します。フォーム・ログイン・ページに HTML を使用する場合、 パスワード・フォーム・フィールドを autocomplete="off" に設定して、 Web ブラウザーでのパスワードの自動入力を使用不可にします。 例:
<form method="POST" action="j_security_check"> <input type="text" name="j_username"> <input type="password" name="j_password" autocomplete="off"> </form> - 「すべて」の認証セキュリティー制約 (**) を指定します。特別な役割名である ** は、 任意の認証済みユーザーを示します。 許可制約内に ** が表示される場合、 ユーザーが認証されていれば、ユーザーにはその制約内に指定されたメソッドへのアクセス権があります。 アプリケーション・バインディングでユーザーがこの役割にマップされる必要はありません。 例:
<security-constraint id="SecurityConstraint_1"> <web-resource-collection id="WebResourceCollection_1"> <web-resource-name>Protected with ** role</web-resource-name> <url-pattern>/AnyAuthSecurityConstraint</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <auth-constraint id="AuthConstraint_1"> <role-name>**</role-name> </auth-constraint> </security-constraint>isUserInRole()メソッドが役割名**を指定して呼び出された場合、isUserInRole()はユーザーが認証されていれば true を返します。**が構成で security-role 内に定義された役割である場合は、 これが何らかの特別な認証済みユーザー役割のように扱われることはありません。isUserInRoleが true を返すには、ユーザーがアプリケーション・バインディングでそのロールにマップされている必要があります。 web.xmlファイル内にdeny-uncovered-http-methodsフラグを指定します。web.xmlファイル内にdeny-uncovered-http-methodsエレメントが指定されている場合、 コンテナーは、カバーされていない HTTP メソッド (要求 URL に最もよく一致する URL パターンの結合セキュリティー制約内に列挙されていない HTTP メソッド) をすべて拒否します。403 (SC_FORBIDDEN)状況コードが返されます。 例:<servlet-mapping id="ServletMapping_1"> <servlet-name>MyServlet</servlet-name> <url-pattern>/MyURLPattern</url-pattern> </servlet-mapping> <deny-uncovered-http-methods/> <!-- SECURITY CONSTRAINTS --> <security-constraint id="SecurityConstraint_1"> <web-resource-collection id="WebResourceCollection_1"> <web-resource-name>Protected with Employee or Manager roles</web-resource-name> <url-pattern>/MyURLPattern</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <auth-constraint id="AuthConstraint_1"> <role-name>Employee</role-name> <role-name>Manager</role-name> </auth-constraint> </security-constraint>web.xmlファイルにdeny-uncovered-http-methodsエレメントが指定されている場合、 各サーブレット内で URL パターンごとにメッセージがmessages.logファイルに記録され、そのメッセージでは、 カバーされていないメソッドが示され、また、それらのカバーされていないメソッドは保護されず、アクセス可能ではないということが説明されます。 例:For URL MyURLPattern in servlet MyServlet, the following HTTP methods are uncovered, and not accessible: DELETE OPTIONS HEAD PUT TRACEweb.xmlファイルにdeny-uncovered-http-methodsエレメントが指定されていない場合、 各サーブレット内で URL パターンごとにメッセージがmessages.logファイルに記録され、そのメッセージでは、 カバーされていないメソッドが示され、また、それらのカバーされていないメソッドは保護されず、アクセス可能であるということが説明されます。 例:For URL MyURLPattern in servlet MyServlet, the following HTTP methods are uncovered, and accessible: DELETE OPTIONS HEAD PUT TRACE
- ログイン・フォームに autocomplete=off を指定します。