From 7ff3aba0c0657b641224f6e71819f9dc7ab786e5 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 10 Jun 2010 21:31:13 +0000 Subject: [PATCH] Monotone-Parent: 85e21021232d18a3c2b1b1d16cf6d52237236f29 Monotone-Revision: 002a7f40ed2519734c4baf4cd4433ecc02b46d54 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-06-10T21:31:13 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 4 ++ UI/MainUI/SOGoUserHomePage.m | 72 +++++++++++++++++++++++++----------- 2 files changed, 54 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 988949c41..b058a15b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2010-06-10 Wolfgang Sourdeau + * UI/MainUI/SOGoUserHomePage.m (-logoffAction): split method in + smaller submethods for the sake of clarity. Also, we provide as + "CAS" mode where the redirection is made to the CAS logout page. + * SoObjects/SOGo/SOGoCASSession.m (+CASSessionWithTicket:fromProxy:): added a new "fromProxy" parameter. (+CASSessionWithIdentifier:fromProxy:): idem. diff --git a/UI/MainUI/SOGoUserHomePage.m b/UI/MainUI/SOGoUserHomePage.m index d8b3c9ba4..da1808fe7 100644 --- a/UI/MainUI/SOGoUserHomePage.m +++ b/UI/MainUI/SOGoUserHomePage.m @@ -35,11 +35,13 @@ #import #import +#import #import #import #import #import #import +#import #import #import #import @@ -228,41 +230,67 @@ return response; } +- (NSString *) _logoutRedirectURL +{ + NSString *redirectURL; + SOGoSystemDefaults *sd; + id container; + + sd = [SOGoSystemDefaults sharedSystemDefaults]; + if ([[sd authenticationType] isEqualToString: @"cas"]) + redirectURL = [SOGoCASSession CASURLWithAction: @"logout" + andParameters: nil]; + else + { + container = [[self clientObject] container]; + redirectURL = [container baseURLInContext: context]; + } + + return redirectURL; +} + +- (WOCookie *) _logoutCookieWithDate: (NSCalendarDate *) date +{ + SOGoWebAuthenticator *auth; + NSString *cookieName, *appName; + WOCookie *cookie; + + cookie = nil; + + auth = [[self clientObject] authenticatorInContext: context]; + if ([auth respondsToSelector: @selector (cookieNameInContext:)]) + { + cookieName = [auth cookieNameInContext: context]; + if ([cookieName length]) + { + cookie = [WOCookie cookieWithName: cookieName value: @"discard"]; + appName = [[context request] applicationName]; + [cookie setPath: [NSString stringWithFormat: @"/%@/", appName]]; + [cookie setExpires: [date yesterday]]; + } + } + + return cookie; +} + - (id ) logoffAction { WOResponse *response; WOCookie *cookie; - SOGoWebAuthenticator *auth; - id container; NSCalendarDate *date; - NSString *userName, *cookieName, *appName; - - container = [[self clientObject] container]; + NSString *userName; userName = [[context activeUser] login]; [self logWithFormat: @"user '%@' logged off", userName]; - response = [context response]; - [response setStatus: 302]; - [response setHeader: [container baseURLInContext: context] - forKey: @"location"]; + response = [self redirectToLocation: [self _logoutRedirectURL]]; date = [NSCalendarDate calendarDate]; [date setTimeZone: [NSTimeZone timeZoneWithAbbreviation: @"GMT"]]; - auth = [[self clientObject] authenticatorInContext: context]; - if ([auth respondsToSelector: @selector (cookieNameInContext:)]) - cookieName = [auth cookieNameInContext: context]; - else - cookieName = nil; - if ([cookieName length]) - { - cookie = [WOCookie cookieWithName: cookieName value: @"discard"]; - appName = [[context request] applicationName]; - [cookie setPath: [NSString stringWithFormat: @"/%@/", appName]]; - [cookie setExpires: [date yesterday]]; - [response addCookie: cookie]; - } + cookie = [self _logoutCookieWithDate: date]; + if (cookie) + [response addCookie: cookie]; [response setHeader: [date rfc822DateString] forKey: @"Last-Modified"]; [response setHeader: @"no-store, no-cache, must-revalidate,"