簡體   English   中英

在Jetty9 WebAppContexts之間實現SSO

[英]Implementing SSO between Jetty9 WebAppContexts

我正在開發的Jetty 9應用程序會自動掃描一組JarFiles中的web.xml,然后以編程方式將包含的webapps導入為WebAppContexts。 我需要在各個Web應用之間實現單點登錄,如Jetty 6的以下教程所述: http : //docs.codehaus.org/display/JETTY/Single+Sign+On+-++Jetty+HashSSORealm 不幸的是,HashSSORealm似乎已從Jetty中刪除。 是否有可行的方法來實現簡單的SSO?

我確實找到了推薦Fediz碼頭插件的帖子,但是如果存在此類問題,我更願意使用本地碼頭解決方案: http : //dev.eclipse.org/mhonarc/lists/jetty-users/msg03176.html

更多信息:

中心問題似乎是每個WebAppContext必須具有自己的SessionManager,即使使用相同的cookie,WebAppContext也無法彼此共享信息。

我解決了這個問題-您只需要將相同的SessionManager實例分配給每個WebAappContext的SessionManager。 假設所有WebAppContexts都分組在/ webapps /上下文路徑下,它將看起來像這樣:

 // To be passed to all scanned webapps. Ensures SSO between contexts
SessionManager sessManager = new HashSessionManager();
SessionCookieConfig config = sessManager.getSessionCookieConfig();
config.setPath("/webapps/"); // Ensures all webapps share the same cookie

// Create the Handler (a.k.a the WebAppContext).
App app = new App(deployer, provider, module.getFile().getAbsolutePath());
WebAppContext handler = (WebAppContext)app.getContextHandler(); // getContextHandler does the extraction
// Consolidating all scanned webapps under a single context path allows SSO
handler.setContextPath("/webapps" + handler.getContextPath());
// Cookies need to be shared between webapps for SSO
SessionHandler sessHandler = handler.getSessionHandler();
sessHandler.setSessionManager(sessManager);

如果跨WebAppContext共享SessionManager,則所有這些WebAppContext都共享完全相同的會話實例。 Servlet規范說,WebAppContexts應該共享會話ID, 而不是會話內容。

一月

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM