- - PR -
Tomcat:security-constraintを複数使用してのアクセス制限
1
| 投稿者 | 投稿内容 |
|---|---|
|
投稿日時: 2004-08-19 18:27
Strutsを使ってWebアプリケーションを作成しているSEです。
Tomcatの<security-constraint>タグを使用して、 ユーザ(role)ごとにアクセスできるページを制限しようとしました。 ・制限事項 1./hoge/group01/* にはROLE_adminを持ってる人がアクセスできる 2./hoge/groupAll/* にはROLE_adminおよびROLE_DEMOを持ってる人がアクセスでる という設定を行いたいのですが、下記のソースの通りに設定するとROLE_DEMOを持っているユーザでも /hoge/group01/*にアクセスできてしまいました。 このように<security-constraint>を複数にわけて成功している方はいませんでしょうか? ※もしかして、ログイン後(FORM認証)はアクセス制限はできないのか?? 以下、環境とソースです。 OS:Windows 2000 JAVA:JDK1.4.2_05 TOMCAT:5.0.27 Apache:2.0.45 DB:Postgres7.4 /*** web.xml ***/ <security-constraint> <web-resource-collection> <web-resource-name>group01</web-resource-name> <url-pattern>/hoge/group01/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>ROLE_admin</role-name> </auth-constraint> </security-constraint> <security-constraint> <web-resource-collection> <web-resource-name>all</web-resource-name> <url-pattern>/hoge/groupAll/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>ROLE_admin</role-name> <role-name>ROLE_DEMO</role-name> </auth-constraint> </security-constraint> <login-config> <auth-method>FORM</auth-method> <realm-name>Example Form-Based Authentication Area</realm-name> <form-login-config> <form-login-page>/login.jsp</form-login-page> <form-error-page>/login.jsp</form-error-page> </form-login-config> </login-config> <security-role> <role-name>ROLE_admin</role-name> </security-role> <security-role> <role-name>ROLE_DEMO</role-name> </security-role> |
|
投稿日時: 2004-08-23 15:52
環境が異なるため役に立たないかもしれませんが、
次の環境および定義ではうまくいっています。 ちなみに、レルムはJNDIのDataSourceRealm経由でJDBC接続しています。 OS:Windows 2000 JAVA:JDK1.4.2_03 TOMCAT:jakarta-tomcat-4.1.27.exe <security-constraint> <display-name>Security Constraint</display-name> <web-resource-collection> <web-resource-name>Protected Area</web-resource-name> <!-- Define the context-relative URL(s) to be protected --> <url-pattern>*.jsp</url-pattern> <url-pattern>*.do</url-pattern> <!-- If you list http methods, only those methods are protected --> <http-method>DELETE</http-method> <http-method>GET</http-method> <http-method>POST</http-method> <http-method>PUT</http-method> </web-resource-collection> <auth-constraint> <!-- Anyone with one of the listed roles may access this area --> <role-name>*</role-name> </auth-constraint> </security-constraint> <security-constraint> <display-name>Security Constraintn</display-name> <web-resource-collection> <web-resource-name>Protected Area</web-resource-name> <!-- Define the context-relative URL(s) to be protected --> <url-pattern>*.txt</url-pattern> <!-- If you list http methods, only those methods are protected --> <http-method>DELETE</http-method> <http-method>GET</http-method> <http-method>POST</http-method> <http-method>PUT</http-method> </web-resource-collection> <auth-constraint> <!-- Anyone with one of the listed roles may access this area --> <role-name>SYSACCMAN</role-name> </auth-constraint> </security-constraint> 以上 |
|
投稿日時: 2004-08-23 18:07
security-constraintを複数設定した場合だけうまくいかないのでしょうか?
一つだけ設定した場合にうまくいっていますか? アクセス制限したいリソースへ forward しているということはありませんか? #forward の場合は security-constraint のチェックは行われません |
1
