私は、EJB セキュリティと GlassFish の認証、承認メカニズムに非常に慣れていません。jdbc
レルムがありsun-web.xml
、web.xml
ロールをマップしてページへのアクセスを制限するように構成されています。
ただし、私の問題は、すべてのページへのアクセスを制限すると、ウェルカムページをロードする前に (BASIC 認証を使用して) 機能し、ログインポップアップがトリガーされることです。
<web-resource-collection>
<web-resource-name>All Pages</web-resource-name>
<description/>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>HEAD</http-method>
<http-method>PUT</http-method>
<http-method>OPTIONS</http-method>
<http-method>TRACE</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
しかし、フォルダー内のページへのアクセスを制限するとsecurity
、GlassFish はログインを要求せず、ユーザーを制限されたページにリダイレクトします。
<web-resource-collection>
<web-resource-name>All Pages</web-resource-name>
<description/>
<url-pattern>/security/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>HEAD</http-method>
<http-method>PUT</http-method>
<http-method>OPTIONS</http-method>
<http-method>TRACE</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>`
この問題の解決を手伝ってください。よろしくお願いします。
セキュリティマネージャーをオンにした後、これらのエントリも見つかりました
Processing login with credentials of type: class com.sun.enterprise.security.auth.login.PasswordCredential
Logging in user [admin] into realm: admin-realm using JAAS module: fileRealm
Login module initialized: class com.sun.enterprise.security.auth.login.FileLoginModule
File login succeeded for: admin
JAAS login complete.
JAAS authentication committed.
Password login succeeded for : admin
permission check done to set SecurityContext
Set security context as user: admin
[Web-Security] hasResource perm: (javax.security.jacc.WebResourcePermission /faces/security/UserRedirect.jsp GET)
jdbcrealm を使用するのではなく、admin-realm の admin プリンシパルが自動的に認証され、アプリケーションに使用されるようです。これを修正する方法について何か考えはありますか?
アップデート
申し訳ありませんが、認証を確認するフォームに変更しました。再度BASICに戻しました。はい、jdbcrealm という名前をデフォルトのレルムとして使用しています。
そうですよね…まさにその通りです
GlassFish はログイン フォーム ページにリダイレクトせず、制限されたリソースへのアクセスは制限されません
admin-realm admin が自動的に認証され、制限されたページにアクセスしようとすると、認証されたユーザーがチェックされ、管理者であり、ページへの権限があるため、ページにアクセスでき、ログインを求められないためだと思います。
これらは、アプリケーションを実行し、glass fish の管理コンソールにログインしようとしていないときにも表示されます
Processing login with credentials of type: class com.sun.enterprise.security.auth.login.PasswordCredential
Logging in user [admin] into realm: admin-realm using JAAS module: fileRealm
Login module initialized: class com.sun.enterprise.security.auth.login.FileLoginModule
File login succeeded for: admin
JAAS login complete.
JAAS authentication committed.
Password login succeeded for : admin
permission check done to set SecurityContext
Set security context as user: admin
これらも
(unresolved javax.security.jacc.WebUserDataPermission /security/* null)
(unresolved javax.security.jacc.WebUserDataPermission /:/security/* null)
(unresolved com.sun.corba.ee.impl.presentation.rmi.DynamicAccessPermission access null)
(unresolved javax.security.jacc.WebResourcePermission /:/security/* null)
(unresolved javax.security.jacc.WebResourcePermission /security/* !DELETE,GET,HEAD,OPTIONS,POST,PUT,TRACE)
(unresolved com.sun.enterprise.security.CORBAObjectPermission * *)
更新 2
<url-pattern>/*</url-pattern>
代わりに使ってみた<url-pattern>/security/*</url-pattern>
興味深いことに、これは私がトレースで得たものです。
Processing login with credentials of type: class com.sun.enterprise.security.auth.login.PasswordCredential
Logging in user [employee] into realm: emsSecurity using JAAS module: jdbcRealm
Login module initialized: class com.sun.enterprise.security.auth.login.JDBCLoginModule
JDBC login succeeded for: employee groups:[Ljava.lang.String;@16bfca4
JAAS login complete.
JAAS authentication committed.
Password login succeeded for : employee
permission check done to set SecurityContext
Set security context as user: employee
アクセス拒否ページに移動します。
「HTTP ステータス 403 - 要求されたリソースへのアクセスが拒否されました」
ユーザーがログイン資格情報を送信せずに、glassfish がユーザーの従業員を認証する方法がわかりません。「従業員のパスワード ログインに成功しました」とさえ表示されます。この問題を解決するのを手伝ってください。
何よりも、ご尽力いただき、誠にありがとうございました。私はまだ問題に悩まされています。ここにxmlファイルを投稿しています。
sun-web.xml
<security-role-mapping>
<role-name>Employee</role-name>
<group-name>Employee</group-name>
web.xml
<security-constraint>
<display-name>Login Constraint</display-name>
<web-resource-collection>
<web-resource-name>User Redirect page</web-resource-name>
<description/>
<url-pattern>/security/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>HEAD</http-method>
<http-method>PUT</http-method>
<http-method>OPTIONS</http-method>
<http-method>TRACE</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint>
<description/>
<role-name>Employee</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>deliverySecurity</realm-name>
<form-login-config>
<form-login-page>/Login.jsp</form-login-page>
<form-error-page>/index.jsp</form-error-page>
</form-login-config>
</login-config>
<security-role>
<description/>
<role-name>Employee</role-name>
</security-role>
また、スタック トレースもありません。例外はありません。認証要件がないかのように、ユーザーは保護されたページにリダイレクトされます。これは、Netbeans 6.5.1 と Glassfish v2 を使用した jsf ビジュアル Web 開発プロジェクトです。どうもありがとう。