[英]Wildfly SSO Logout Not Working - Session is Still Valid
我正在運行Wildfly,並且在用戶注銷時遇到會話無效的問題。 我已經設置了一個自定義數據庫登錄模塊,但是注銷功能沒有。 我已經粘貼了相關的standalone.xml,jboss-web.xml和我的servlet注銷代碼。
問題是注銷后會話不會失效。 使用相同的JSESSIONIDSSO cookie,即使在注銷后,用戶仍然可以訪問需要角色的頁面。 我已經測試過角色是否正常工作 - 在登錄之前,需要角色的頁面無法訪問。 登錄后,可以訪問它們。 注銷后,仍然可以訪問它們。
有沒有其他人遇到過這些問題,或者你知道我的錯誤配置是什么嗎?
standalone.xml
<security-domain name="myname-form" cache-type="default">
<authentication>
<login-module code="com.myname.DatabaseModLoginModule" flag="sufficient">
<module-option name="securityDomain" value="jsse-myname"/>
<module-option name="verifier" value="com.myname.X509Verifier"/>
<module-option name="dsJndiName" value="java:/jdbc/myds"/>
<module-option name="rolesQuery" value="exec h_Get_UserRoles ?, 1"/>
<module-option name="fieldToSearchMap" value="CN=TEST"/>
<module-option name="logQuery" value="exec h_Log_login_Attempt ?,?"/>
<module-option name="certLogDir" value="C:\tools\wildfly\standalone\log\failedcerts"/>
</login-module>
</authentication>
</security-domain>
的jboss-web.xml中
<jboss-web>
<security-domain flushOnSessionInvalidation="true">myname-form</security-domain>
<valve>
<class-name>org.apache.catalina.authenticator.SingleSignOn</class-name>
</valve>
<context-root>/myname-form</context-root>
</jboss-web>
ServletLogout.java
public class LogoutServlet extends HttpServlet {
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
response.setHeader("Cache-Control", "no-cache, no-store");
response.setHeader("Pragma", "no-cache");
response.setHeader("Expires", new java.util.Date().toString());
if (request.getSession(false) != null) {
request.getSession(false).invalidate();
}
if (request.getSession() != null) {
request.getSession().invalidate();
}
request.logout();
response.sendRedirect(request.getScheme()+"://"+request.getServerName());
}
}
我使用的是Wildfly-8.1,我也遇到過很多SSO問題。 首先,如前所述,您需要在銷毀會話時手動刷新緩存:
@WebListener
public class SessionListener implements HttpSessionListener {
@Resource(name = "java:jboss/jaas/app/authenticationMgr")
private CacheableManager<?, Principal> authenticationManager;
@Override
public void sessionCreated(HttpSessionEvent httpSessionEvent) {
}
@Override
public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
// Flushes credentials.
Principal principal = (Principal) httpSessionEvent.getSession()
.getAttribute("principal");
if (principal != null) {
authenticationManager.flushCache(principal);
}
}
}
Wildfly已將默認Web容器切換為Undertow,因此閥門不能再使用了。 您可以從jboss-web.xml中刪除該部分
要啟用SSO,您需要編輯standalone.xml並在上流子系統中添加“單點登錄”選項(每個主機配置SSO):
<subsystem xmlns="urn:jboss:domain:undertow:1.1">
<buffer-cache name="default"/>
<server name="default-server">
<http-listener name="default" socket-binding="http"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
<single-sign-on path="/"/>
</host>
</server>
<servlet-container name="default">
<jsp-config/>
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
</handlers>
<filters>
<response-header name="server-header" header-name="Server" header-value="WildFly/8"/>
<response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
</filters>
</subsystem>
但仍然不夠,因為我必須退出兩次才能注銷。 在此論壇上關注和討論之后: Wildfly SSO,是否支持會話超時和注銷? 我必須使用此論壇上的修補程序修補Undertow模塊並將其安裝在Wildfly-8.1中
似乎它與這個 JIRA問題有關,在Wildfly 8中尚未解決,但只有9個問題。
我有同樣的問題。
我已經從Wildfly8.1.0.Final更新到Wildfly8.2.0.Final,問題已經消失。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.