From 89d3d4b413a75bad1a09eeb5688156d0f0c040c9 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Thu, 12 Aug 2010 17:56:18 +0000 Subject: [PATCH] See ChangeLog Monotone-Parent: 5016da15e7302739b395754fe5a9d170409343ae Monotone-Revision: f6a0b62965278336b461dac36045bfae5fc07f0a Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2010-08-12T17:56:18 --- ChangeLog | 18 +++++++++++++ NEWS | 1 + UI/Common/UIxPageFrame.m | 9 +++++++ UI/MainUI/SOGoRootPage.m | 5 ++++ UI/MainUI/product.plist | 7 +++++- UI/Templates/UIxPageFrame.wox | 6 +++++ UI/WebServerResources/generic.js | 43 ++++++++++++++++++++++++-------- 7 files changed, 78 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5f16b1b4b..223e5b6e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2010-08-12 Wolfgang Sourdeau + + * UI/WebServerResources/generic.js: (onAjaxRequestStateChange): + when using CAS authentication and when the return code is 0 and + when the request status is 4, chances are that the initial ajax + request failed due to the expiration of the CAS ticket entry in + memcached. In FF 3.5 and above, a bug prevents the initial cookie + from being given back to the reauthentication redirect from an + AJAX request. Therefore we open a window that will do this for us + and will close one the authentication has succeeded again. + + * UI/MainUI/SOGoRootPage.m (-revoverAction): new fake action that + perform the CAS redirection and then trigger the respawn of the + initial request. + + * UI/Common/UIxPageFrame.m (-usesCASAuthentication): new accessor + used for recovery of redirected requests. + 2010-08-11 Francis Lachapelle * UI/WebServerResources/MailerUI.js (refreshMessage): if the diff --git a/NEWS b/NEWS index 5899a341e..0d7412b5b 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ - added Polish translation - added crypt support to SQL sources - updated Ukrainian translation +- added the caldav-auto-schedule capability 1.3-20100721 (1.3.0) -------------------- diff --git a/UI/Common/UIxPageFrame.m b/UI/Common/UIxPageFrame.m index cc81a8e3f..ec6b0bb08 100644 --- a/UI/Common/UIxPageFrame.m +++ b/UI/Common/UIxPageFrame.m @@ -400,6 +400,15 @@ && [user isSuperUser]); } +- (BOOL) usesCASAuthentication +{ + SOGoSystemDefaults *sd; + + sd = [SOGoSystemDefaults sharedSystemDefaults]; + + return [[sd authenticationType] isEqualToString: @"cas"]; +} + - (NSString *) userIdentification { /* The "identification" term is used in the human sense here. */ diff --git a/UI/MainUI/SOGoRootPage.m b/UI/MainUI/SOGoRootPage.m index 842da7402..18cba979e 100644 --- a/UI/MainUI/SOGoRootPage.m +++ b/UI/MainUI/SOGoRootPage.m @@ -435,4 +435,9 @@ return response; } +- (id) recoverAction +{ + return [self jsCloseWithRefreshMethod: @"recoverRequest();"]; +} + @end /* SOGoRootPage */ diff --git a/UI/MainUI/product.plist b/UI/MainUI/product.plist index 7bb31f229..0def5f8f3 100644 --- a/UI/MainUI/product.plist +++ b/UI/MainUI/product.plist @@ -106,10 +106,15 @@ }; }; methods = { - view = { + view = { protectedBy = ""; pageName = "SOGoRootPage"; }; + recover = { + protectedBy = "View"; + pageName = "SOGoRootPage"; + actionName = "recover"; + }; index = { protectedBy = ""; pageName = "SOGoRootPage"; diff --git a/UI/Templates/UIxPageFrame.wox b/UI/Templates/UIxPageFrame.wox index df00f15f2..ca5a71775 100644 --- a/UI/Templates/UIxPageFrame.wox +++ b/UI/Templates/UIxPageFrame.wox @@ -122,6 +122,12 @@ var IsSuperUser = false; + var usesCASAuthentication = true; + + var usesCASAuthentication = false; + var UserFolderURL = ''; diff --git a/UI/WebServerResources/generic.js b/UI/WebServerResources/generic.js index 91be90dbc..0ff1b1c12 100644 --- a/UI/WebServerResources/generic.js +++ b/UI/WebServerResources/generic.js @@ -27,6 +27,7 @@ var logConsole; var logWindow = null; var queryParameters; +var recoveryRequest = null; var menus = new Array(); var search = {}; @@ -246,15 +247,26 @@ function createHTTPClient() { function onAjaxRequestStateChange(http) { try { - if (http.readyState == 4 - && activeAjaxRequests > 0) { - if (!http.aborted) - http.callback(http); - activeAjaxRequests--; - checkAjaxRequestsState(); - http.onreadystatechange = Prototype.emptyFunction; - http.callback = Prototype.emptyFunction; - http.callbackData = null; + if (http.readyState == 4) { + if (http.status == 0 && usesCASAuthentication) { + activeAjaxRequests--; + checkAjaxRequestsState(); + recoveryRequest = http; + var urlstr = ApplicationBaseURL; + if (!urlstr.endsWith('/')) + urlstr += '/'; + urlstr += ("../../recover"); + window.open(urlstr, "_blank"); + } + else if (activeAjaxRequests > 0) { + if (!http.aborted) + http.callback(http); + activeAjaxRequests--; + checkAjaxRequestsState(); + http.onreadystatechange = Prototype.emptyFunction; + http.callback = Prototype.emptyFunction; + http.callbackData = null; + } } } catch(e) { @@ -276,6 +288,16 @@ function onAjaxRequestStateChange(http) { } } +function recoverRequest() { + if (recoveryRequest) { + triggerAjaxRequest(recoveryRequest.url, + recoveryRequest.callback, + recoveryRequest.callbackData, + recoveryRequest.paramHeaders); + recoveryRequest = null; + } +} + /* taken from Lightning */ function getContrastingTextColor(bgColor) { var calcColor = bgColor.substring(1); @@ -299,9 +321,10 @@ function triggerAjaxRequest(url, callback, userdata, content, headers) { http.open("POST", url, true); http.url = url; + http.paramHeaders = headers; http.callback = callback; http.callbackData = userdata; - http.onreadystatechange = function() { onAjaxRequestStateChange(http);}; + http.onreadystatechange = function() { onAjaxRequestStateChange(http); }; // = function() { // // log ("state changed (" + http.readyState + "): " + url); // };