我們正在構建具有2步身份驗證過程的Worklight應用程序。Multi-Realm身份驗證(Forms +自定義身份驗證器)
第1步:窗體身份驗證
我們正在使用的開箱WASLTPARealm這驗證我們對在WebSphere定製JAAS模塊,並返回一個LTPA令牌。這按預期工作。
步驟2:自定義身份驗證
第二個步驟是一個自定義的身份驗證和登錄模塊其中:
- 讀取在步驟1中
- 已設置的LTPA餅乾使POST請求到另一個應用程序與LTPA cookie(這2個應用程序是通過單一登錄信任的)
- POST請求返回附加會話cookie的響應
- 用戶已通過身份驗證
問題是使用文檔中提供的客戶端代碼時,Custom Authenticator不會觸發。基本上
的customAuthenticator經由通常
var customAuthenticator = WL.Client.createChallengeHandler("MyCustomRealm");
然後,在客戶端代碼進一步向下
var reqURL = '/my_custom_auth_request_url';
var options = {};
options.parameters = {};
options.headers = {};
customAuthenticator.submitLoginForm(reqURL, options, customAuthenticator.submitLoginFormCallback);
結果在404
[27/05/13 10:35:07:616 NZST] 00000326 WebSphereForm I com.worklight.core.auth.ext.WebSphereFormBasedAuthenticator processRequest FWLSE0055I: Not recognized.
[27/05/13 10:35:07:616 NZST] 00000326 Authenticatio E com.worklight.core.auth.impl.AuthenticationFilter doFilter FWLSE0048E: Unhandled exception caught: SRVE0190E: File not found: /apps/services/my_custom_auth_request_url
java.io.FileNotFoundException: SRVE0190E: File not found: /apps/services/my_custom_auth_request_url
創建
發生這種情況的原因是請求被WebSphereFormBasedAuthenticator而不是我們的自定義身份驗證器拾取。
我們通過
public AuthenticationResult processRequest(HttpServletRequest request, HttpServletResponse response, boolean isAccessToProtectedResource) throws IOException, ServletException {
logger.info("Request URL is: " + request.getRequestURI());
寫請求URL到自定義認證裏面的日誌,但該行從來沒有被擊中。
2個驗證器可以並排工作嗎?我看到的行爲是
var wlFormsAuthenticator = WL.Client.createChallengeHandler("WASLTPARealm");
和
var customAuthenticator = WL.Client.createChallengeHandler("MyCustomRealm");
似乎搞混。我認爲在customAuthenticator上調用submitLoginForm
不應該被WebSphereForms認證器獲取,而應該轉到我們自定義的認證器。
您能否澄清預期的行爲和潛在的解決方法?
此外,這是什麼工作,呼籲
WL.Client.login("MyCustomRealm", {
onSuccess: function() {
},
onFailure: function() {
}
});
在這種情況下,Java代碼被擊中,我們成功地驗證但,網址是
http://localhosT:9080/worklight/apps/services/api/MyApp/common/login
而不是my_custom_auth_request_url
這意味着我們無法過濾掉我們的Java代碼中的請求。
希望這是有道理的。提前致謝。
不要混淆變量的命名。他們應該被稱爲'wlFormsChallengeHandler'和'customChallengeHandler'。我確實理解客戶端和服務器端實體的概念和區別。正如我所提到的,我已經**使用'WL.Client.login()'方法,但是正在使用的URL不是我在客戶端代碼中指定的自定義URL,而是它的'baseurl/login '因此無法在** Java **代碼中執行過濾。 – Marko
您能解釋一下您將用於Forms Authenticator和Custom Authenticator解決方案組合的過程嗎,特別是在客戶端代碼中? – Marko
/my_custom_auth_request_url僅用於發送憑證。 WL.Client.login(「realm」)應該向/ login API發出請求,這是可以的。發出WL.Client.login(..)請求時會發生什麼?你有什麼迴應? – Anton