Spring Security を使用して、GWT の最初のページ アプリケーション"/HumanResources.html"へのアクセスを保護しています。ユーザーの資格情報が正しいかどうかを確認し (ldap コンテンツと比較して)、ユーザーがデータベース (カスタム承認テーブル) に存在するかどうかを確認します。
初回のユーザーログインは問題なく、ユーザーログアウトすると「.jsp」ページが表示されます。しかし、再度「HumanResources.html」ページにアクセスしようとすると、どうやら認証が無視されて (ログインフォームが表示されず)、ページが表示されてしまいます。インターフェイスのみが表示され、データはセキュリティで保護された RPC サービスによって取得されます。
この問題は、外部 Tomcat サーバー (Firefox および Chrome でテスト済み) で発生しますが、GWT Dev モードでは発生しません。CTRL + F5 は機能しているようで、他のキャッシュの問題を探しましたが、役に立ちませんでした。
誰でも私を助けることができますか?
私のsecurity-applicationContext.xmlの一部:
<http use-expressions="true" auto-config="false">
<intercept-url pattern="/HumanResources.html" access="isAuthenticated()" />
<form-login
login-page='/login.jsp'
authentication-failure-url = "/login.jsp?login_error=1"
authentication-success-handler-ref="HRAuthenticationHandler" />
<logout
logout-url="/logout"
logout-success-url="/logout.jsp"
delete-cookies="JSESSIONID"/>
</http>
<beans:bean id="HRAuthenticationHandler" class="lu.sfeir.candidate.server.auth.HRAuthenticationHandler">
<beans:property name="useReferer" value="true" />
</beans:bean>
<ldap-server url="${ldap.serverUrl}" manager-dn="${ldap.adminLogin}" manager-password="${ldap.adminPassword}" />
<authentication-manager>
<ldap-authentication-provider
group-search-base="${ldap.groups}"
user-search-base="${ldap.users}"
user-search-filter="${ldap.userId}">
</ldap-authentication-provider>
</authentication-manager>
および私のカスタムAuthenticationHandler 実装:
public class HRAuthenticationHandler extends SavedRequestAwareAuthenticationSuccessHandler {
@Autowired
private AuthorizedUsersDao usersDao;
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException,
ServletException {
// Check if the user exist in the DB
if(usersDao.findUser(((UserDetails)authentication.getPrincipal()).getUsername())) {
// Redirect to home page
super.onAuthenticationSuccess(request, response, authentication);
} else {
// Redirect to error page
response.sendRedirect("/spring_security_login?login_error");
}
}
}