(feat) added AngularJS's XSRF support (#3246)

pull/207/head
Ludovic Marcotte 2016-04-26 11:06:44 -04:00
parent 2da7a04bac
commit 582baf2960
40 changed files with 224 additions and 129 deletions

1
NEWS
View File

@ -5,6 +5,7 @@ New features
- [core] new database structure options to make SOGo use a total of nine tables - [core] new database structure options to make SOGo use a total of nine tables
- [core] new user-based rate-limiting support for all SOGo requests (#3188) - [core] new user-based rate-limiting support for all SOGo requests (#3188)
- [web] toolbar of all-day events can be expanded to display all events - [web] toolbar of all-day events can be expanded to display all events
- [web] added AngularJS's XSRF support (#3246)
Enhancements Enhancements
- [web] updated Angular Material to version 1.0.6 - [web] updated Angular Material to version 1.0.6

View File

@ -65,6 +65,7 @@
- (BOOL) uixDebugEnabled; - (BOOL) uixDebugEnabled;
- (BOOL) easDebugEnabled; - (BOOL) easDebugEnabled;
- (BOOL) xsrfValidationEnabled;
- (NSString *) pageTitle; - (NSString *) pageTitle;
- (NSString *) helpURL; - (NSString *) helpURL;

View File

@ -430,6 +430,18 @@ _injectConfigurationFromFile (NSMutableDictionary *defaultsDict,
return [self boolForKey: @"SOGoEASDebugEnabled"]; return [self boolForKey: @"SOGoEASDebugEnabled"];
} }
- (BOOL) xsrfValidationEnabled
{
id o;
if (!(o = [self objectForKey: @"SOGoXSRFValidationEnabled"]))
{
return YES;
}
return [o boolValue];
}
- (NSString *) pageTitle - (NSString *) pageTitle
{ {
return [self stringForKey: @"SOGoPageTitle"]; return [self stringForKey: @"SOGoPageTitle"];

View File

@ -21,7 +21,7 @@ CommonUI_OBJC_FILES += \
UIxTopnavToolbar.m \ UIxTopnavToolbar.m \
UIxToolbar.m \ UIxToolbar.m \
\ \
WODirectAction+SOGo.m \ SOGoDirectAction.m \
CommonUI_RESOURCE_FILES += \ CommonUI_RESOURCE_FILES += \
product.plist product.plist

View File

@ -1,6 +1,6 @@
/* WODirectAction+SOGo.h - this file is part of SOGo /* SOGoDirectAction.h - this file is part of SOGo
* *
* Copyright (C) 2007-2015 Inverse inc. * Copyright (C) 2007-2016 Inverse inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -26,7 +26,7 @@
@class NSString; @class NSString;
@class WOResponse, WOResourceManager; @class WOResponse, WOResourceManager;
@interface WODirectAction (SOGoExtension) @interface SOGoDirectAction : WODirectAction
- (WOResponse *) responseWithStatus: (unsigned int) status; - (WOResponse *) responseWithStatus: (unsigned int) status;
- (WOResponse *) responseWithStatus: (unsigned int) status - (WOResponse *) responseWithStatus: (unsigned int) status

View File

@ -1,6 +1,6 @@
/* WODirectAction+SOGo.m - this file is part of SOGo /* SOGoDirectAction - this file is part of SOGo
* *
* Copyright (C) 2007-2015 Inverse inc. * Copyright (C) 2007-2016 Inverse inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -26,15 +26,19 @@
#import <SoObjects/SOGo/NSObject+Utilities.h> #import <SoObjects/SOGo/NSObject+Utilities.h>
#import <SoObjects/SOGo/NSDictionary+Utilities.h> #import <SoObjects/SOGo/NSDictionary+Utilities.h>
#import <SoObjects/SOGo/NSString+Crypto.h>
#import <SoObjects/SOGo/NSString+Utilities.h> #import <SoObjects/SOGo/NSString+Utilities.h>
#import <SoObjects/SOGo/SOGoSession.h>
#import <SoObjects/SOGo/SOGoSystemDefaults.h>
#import <SoObjects/SOGo/SOGoWebAuthenticator.h>
#import <NGExtensions/NSObject+Logs.h> #import <NGExtensions/NSObject+Logs.h>
#import "WODirectAction+SOGo.h" #import "SOGoDirectAction.h"
static SoProduct *commonProduct = nil; static SoProduct *commonProduct = nil;
@implementation WODirectAction (SOGoExtension) @implementation SOGoDirectAction
+ (void) initialize + (void) initialize
{ {
@ -205,4 +209,34 @@ static SoProduct *commonProduct = nil;
return url; return url;
} }
//
// Protection against XSRF
//
- (id<WOActionResults>)performActionNamed:(NSString *)_actionName
{
SOGoWebAuthenticator *auth;
NSString *value, *token;
NSArray *creds;
if (![[SOGoSystemDefaults sharedSystemDefaults] xsrfValidationEnabled])
return [super performActionNamed: _actionName];
// We grab the X-XSRF-TOKEN header
token = [[context request] headerForKey: @"X-XSRF-TOKEN"];
// We compare it with our session key
auth = [[WOApplication application]
authenticatorInContext: context];
value = [[context request]
cookieValueForKey: [auth cookieNameInContext: context]];
creds = [auth parseCredentials: value];
value = [SOGoSession valueForSessionKey: [creds lastObject]];
if ([token isEqualToString: [value asSHA1String]])
return [super performActionNamed: _actionName];
return nil;
}
@end @end

View File

@ -1,6 +1,6 @@
/* UIxFolderActions.h - this file is part of SOGo /* UIxFolderActions.h - this file is part of SOGo
* *
* Copyright (C) 2007-2014 Inverse inc. * Copyright (C) 2007-2016 Inverse inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -30,7 +30,9 @@
@class SOGoGCSFolder; @class SOGoGCSFolder;
@class SOGoUserSettings; @class SOGoUserSettings;
@interface UIxFolderActions : WODirectAction #include "SOGoDirectAction.h"
@interface UIxFolderActions : SOGoDirectAction
{ {
SOGoGCSFolder *clientObject; SOGoGCSFolder *clientObject;
LDAPUserManager *um; LDAPUserManager *um;

View File

@ -1,6 +1,6 @@
/* UIxFolderActions.m - this file is part of SOGo /* UIxFolderActions.m - this file is part of SOGo
* *
* Copyright (C) 2007-2015 Inverse inc. * Copyright (C) 2007-2016 Inverse inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -42,8 +42,6 @@
#import <Appointments/SOGoAppointmentFolder.h> #import <Appointments/SOGoAppointmentFolder.h>
#import "WODirectAction+SOGo.h"
#import "UIxFolderActions.h" #import "UIxFolderActions.h"
@implementation UIxFolderActions @implementation UIxFolderActions

View File

@ -1,8 +1,6 @@
/* UIxObjectActions.h - this file is part of SOGo /* UIxObjectActions.h - this file is part of SOGo
* *
* Copyright (C) 2007 Inverse inc. * Copyright (C) 2007-2016 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -23,10 +21,11 @@
#ifndef UIXOBJECTACTIONS_H #ifndef UIXOBJECTACTIONS_H
#define UIXOBJECTACTIONS_H #define UIXOBJECTACTIONS_H
#include "SOGoDirectAction.h"
@class WOResponse; @class WOResponse;
@interface UIxObjectActions : WODirectAction @interface UIxObjectActions : SOGoDirectAction
- (WOResponse *) addUserInAclsAction; - (WOResponse *) addUserInAclsAction;

View File

@ -30,8 +30,6 @@
#import <SOGo/NSDictionary+Utilities.h> #import <SOGo/NSDictionary+Utilities.h>
#import "WODirectAction+SOGo.h"
#import "UIxObjectActions.h" #import "UIxObjectActions.h"
@implementation UIxObjectActions @implementation UIxObjectActions

View File

@ -1,8 +1,6 @@
/* UIxParentFolderActions.h - this file is part of SOGo /* UIxParentFolderActions.h - this file is part of SOGo
* *
* Copyright (C) 2007 Inverse inc. * Copyright (C) 2007-2016 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -23,8 +21,9 @@
#ifndef UIXPARENTFOLDERACTIONS_H #ifndef UIXPARENTFOLDERACTIONS_H
#define UIXPARENTFOLDERACTIONS_H #define UIXPARENTFOLDERACTIONS_H
#include "SOGoDirectAction.h"
@interface UIxParentFolderActions : WODirectAction @interface UIxParentFolderActions : SOGoDirectAction
@end @end
#endif /* UIXPARENTFOLDERACTIONS_H */ #endif /* UIXPARENTFOLDERACTIONS_H */

View File

@ -1,6 +1,6 @@
/* UIxParentFolderActions.m - this file is part of SOGo /* UIxParentFolderActions.m - this file is part of SOGo
* *
* Copyright (C) 2007-2015 Inverse inc. * Copyright (C) 2007-2016 Inverse inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -29,8 +29,6 @@
#import <SOGo/NSDictionary+Utilities.h> #import <SOGo/NSDictionary+Utilities.h>
#import <SOGo/NSString+Utilities.h> #import <SOGo/NSString+Utilities.h>
#import <UI/Common/WODirectAction+SOGo.h>
#import "UIxParentFolderActions.h" #import "UIxParentFolderActions.h"
@implementation UIxParentFolderActions @implementation UIxParentFolderActions

View File

@ -1,8 +1,6 @@
/* UIxContactActions.m - this file is part of SOGo /* UIxContactActions.m - this file is part of SOGo
* *
* Copyright (C) 2010 Inverse inc. * Copyright (C) 2010-2016 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -30,7 +28,7 @@
#import <Contacts/SOGoContactGCSEntry.h> #import <Contacts/SOGoContactGCSEntry.h>
#import <Common/WODirectAction+SOGo.h> #import <Common/SOGoDirectAction.h>
@interface NGVCard (SOGoActionCategory) @interface NGVCard (SOGoActionCategory)
@ -80,7 +78,7 @@
@end @end
@interface UIxContactActions : WODirectAction @interface UIxContactActions : SOGoDirectAction
- (WOResponse *) setCategoryAction; - (WOResponse *) setCategoryAction;
- (WOResponse *) unsetCategoryAction; - (WOResponse *) unsetCategoryAction;

View File

@ -1,34 +1,35 @@
/* /*
Copyright (C) 2004-2005 SKYRIX Software AG Copyright (C) 2006-2016 Inverse inc.
This file is part of OpenGroupware.org. This file is part of SOGo.
OGo is free software; you can redistribute it and/or modify it under SOGo is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any Free Software Foundation; either version 2, or (at your option) any
later version. later version.
OGo is distributed in the hope that it will be useful, but WITHOUT ANY SOGo is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details. License for more details.
You should have received a copy of the GNU Lesser General Public You should have received a copy of the GNU Lesser General Public
License along with OGo; see the file COPYING. If not, write to the License along with SOGo; see the file COPYING. If not, write to the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. 02111-1307, USA.
*/ */
#ifndef __UIxContactsListActions_H__ #ifndef __UIxContactsListActions_H__
#define __UIxContactsListActions_H__ #define __UIxContactsListActions_H__
#import <Common/SOGoDirectAction.h>
@class NSDictionary; @class NSDictionary;
@class NSString; @class NSString;
@protocol SOGoContactObject; @protocol SOGoContactObject;
@interface UIxContactsListActions : WODirectAction @interface UIxContactsListActions : SOGoDirectAction
{ {
NSDictionary *currentContact; NSDictionary *currentContact;

View File

@ -37,9 +37,6 @@
#import <EOControl/EOQualifier.h> #import <EOControl/EOQualifier.h>
#import <EOControl/EOSortOrdering.h> #import <EOControl/EOSortOrdering.h>
#import <Common/WODirectAction+SOGo.h>
#import <SOGo/SOGoUser.h> #import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserSettings.h> #import <SOGo/SOGoUserSettings.h>

View File

@ -1,8 +1,6 @@
/* UIxMailPartICalActions.h - this file is part of SOGo /* UIxMailPartICalActions.h - this file is part of SOGo
* *
* Copyright (C) 2007 Inverse inc. * Copyright (C) 2007-2016 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -23,12 +21,13 @@
#ifndef UIXMAILPARTICALACTIONS_H #ifndef UIXMAILPARTICALACTIONS_H
#define UIXMAILPARTICALACTIONS_H #define UIXMAILPARTICALACTIONS_H
@class iCalCalendar; @class iCalCalendar;
@class SOGoMailBodyPart; @class SOGoMailBodyPart;
@class WOResponse; @class WOResponse;
@interface UIxMailPartICalActions : WODirectAction #import <UI/Common/SOGoDirectAction.h>
@interface UIxMailPartICalActions : SOGoDirectAction
- (WOResponse *) acceptAction; - (WOResponse *) acceptAction;
- (WOResponse *) declineAction; - (WOResponse *) declineAction;

View File

@ -1,6 +1,6 @@
/* UIxMailPartICalActions.m - this file is part of SOGo /* UIxMailPartICalActions.m - this file is part of SOGo
* *
* Copyright (C) 2007-2015 Inverse inc. * Copyright (C) 2007-2016 Inverse inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -32,8 +32,6 @@
#import <NGCards/iCalCalendar.h> #import <NGCards/iCalCalendar.h>
#import <UI/Common/WODirectAction+SOGo.h>
#import <NGImap4/NGImap4EnvelopeAddress.h> #import <NGImap4/NGImap4EnvelopeAddress.h>
#import <Appointments/iCalEvent+SOGo.h> #import <Appointments/iCalEvent+SOGo.h>
@ -239,7 +237,6 @@
WOResponse *response; WOResponse *response;
SOGoAppointmentObject *eventObject; SOGoAppointmentObject *eventObject;
iCalEvent *chosenEvent; iCalEvent *chosenEvent;
//NSException *ex;
chosenEvent = [self _setupChosenEventAndEventObject: &eventObject]; chosenEvent = [self _setupChosenEventAndEventObject: &eventObject];
if (chosenEvent) if (chosenEvent)

View File

@ -1,6 +1,6 @@
/* UIxMailAccountActions.h - this file is part of SOGo /* UIxMailAccountActions.h - this file is part of SOGo
* *
* Copyright (C) 2007-2013 Inverse inc. * Copyright (C) 2007-2016 Inverse inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -21,10 +21,11 @@
#ifndef UIXMAILACCOUNTACTIONS_H #ifndef UIXMAILACCOUNTACTIONS_H
#define UIXMAILACCOUNTACTIONS_H #define UIXMAILACCOUNTACTIONS_H
#import <UI/Common/SOGoDirectAction.h>
@class WOResponse; @class WOResponse;
@interface UIxMailAccountActions : WODirectAction @interface UIxMailAccountActions : SOGoDirectAction
{ {
} }

View File

@ -1,6 +1,6 @@
/* UIxMailAccountActions.m - this file is part of SOGo /* UIxMailAccountActions.m - this file is part of SOGo
* *
* Copyright (C) 2007-2014 Inverse inc. * Copyright (C) 2007-2016 Inverse inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -34,8 +34,6 @@
#import <SOGo/SOGoDomainDefaults.h> #import <SOGo/SOGoDomainDefaults.h>
#import <SOGo/SOGoUser.h> #import <SOGo/SOGoUser.h>
#import "../Common/WODirectAction+SOGo.h"
#import "UIxMailAccountActions.h" #import "UIxMailAccountActions.h"
@implementation UIxMailAccountActions @implementation UIxMailAccountActions

View File

@ -1,6 +1,6 @@
/* UIxMailActions.h - this file is part of SOGo /* UIxMailActions.h - this file is part of SOGo
* *
* Copyright (C) 2007-2013 Inverse inc. * Copyright (C) 2007-2016 Inverse inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -21,8 +21,9 @@
#ifndef UIXMAILACTIONS_H #ifndef UIXMAILACTIONS_H
#define UIXMAILACTIONS_H #define UIXMAILACTIONS_H
#import <UI/Common/SOGoDirectAction.h>
@interface UIxMailActions : WODirectAction @interface UIxMailActions : SOGoDirectAction
@end @end
#endif /* UIXMAILACTIONS_H */ #endif /* UIXMAILACTIONS_H */

View File

@ -37,8 +37,6 @@
#import <SoObjects/SOGo/SOGoUserSettings.h> #import <SoObjects/SOGo/SOGoUserSettings.h>
#import <SoObjects/SOGo/SOGoUserDefaults.h> #import <SoObjects/SOGo/SOGoUserDefaults.h>
#import "../Common/WODirectAction+SOGo.h"
#import "UIxMailActions.h" #import "UIxMailActions.h"
@implementation UIxMailActions @implementation UIxMailActions

View File

@ -21,10 +21,11 @@
#ifndef UIXMAILFOLDERACTIONS_H #ifndef UIXMAILFOLDERACTIONS_H
#define UIXMAILFOLDERACTIONS_H #define UIXMAILFOLDERACTIONS_H
#import <UI/Common/SOGoDirectAction.h>
@class WOResponse; @class WOResponse;
@interface UIxMailFolderActions : WODirectAction @interface UIxMailFolderActions : SOGoDirectAction
- (id <WOActionResults>) createFolderAction; - (id <WOActionResults>) createFolderAction;
- (WOResponse *) renameFolderAction; - (WOResponse *) renameFolderAction;

View File

@ -38,8 +38,6 @@
#import <SOGo/SOGoUser.h> #import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserSettings.h> #import <SOGo/SOGoUserSettings.h>
#import <UI/Common/WODirectAction+SOGo.h>
#import "UIxMailFolderActions.h" #import "UIxMailFolderActions.h"
@implementation UIxMailFolderActions @implementation UIxMailFolderActions
@ -225,7 +223,6 @@
SOGoUserSettings *us; SOGoUserSettings *us;
WOResponse *response; WOResponse *response;
NSException *error; NSException *error;
BOOL moved; BOOL moved;
co = [self clientObject]; co = [self clientObject];
@ -380,20 +377,20 @@
response = nil; response = nil;
if ([value length] > 0) if ([value length] > 0)
{ {
uids = [value componentsSeparatedByString: @","]; uids = [value componentsSeparatedByString: @","];
response = [co archiveUIDs: uids response = [co archiveUIDs: uids
inArchiveNamed: [self labelForKey: @"Saved Messages.zip" inContext: context] inArchiveNamed: [self labelForKey: @"Saved Messages.zip" inContext: context]
inContext: context]; inContext: context];
if (!response) if (!response)
response = [self responseWith204]; response = [self responseWith204];
} }
else else
{ {
jsonResponse = [NSDictionary dictionaryWithObject: [self labelForKey: @"Missing 'uid' parameter." inContext: context] jsonResponse = [NSDictionary dictionaryWithObject: [self labelForKey: @"Missing 'uid' parameter." inContext: context]
forKey: @"message"]; forKey: @"message"];
response = [self responseWithStatus: 500 andJSONRepresentation: jsonResponse]; response = [self responseWithStatus: 500 andJSONRepresentation: jsonResponse];
} }
return response; return response;
} }

View File

@ -1,6 +1,5 @@
/* /*
Copyright (C) 2004-2005 SKYRIX Software AG Copyright (C) 2004-2016 Inverse inc
Copyright (C) 2004-2014 Inverse inc
This file is part of SOGo. This file is part of SOGo.
@ -23,13 +22,14 @@
#ifndef UIXMAILLISTACTIONS_H #ifndef UIXMAILLISTACTIONS_H
#define UIXMAILLISTACTIONS_H #define UIXMAILLISTACTIONS_H
@class NSDictionary; @class NSDictionary;
@class EOQualifier; @class EOQualifier;
@class SOGoDateFormatter; @class SOGoDateFormatter;
@class UIxMailSizeFormatter; @class UIxMailSizeFormatter;
@interface UIxMailListActions : WODirectAction #import <UI/Common/SOGoDirectAction.h>
@interface UIxMailListActions : SOGoDirectAction
{ {
NSArray *sortedUIDs; /* we always need to retrieve all anyway! */ NSArray *sortedUIDs; /* we always need to retrieve all anyway! */
NSArray *messages; NSArray *messages;

View File

@ -58,7 +58,6 @@
#import <SOGo/SOGoUserSettings.h> #import <SOGo/SOGoUserSettings.h>
#import <SOGo/WOResourceManager+SOGo.h> #import <SOGo/WOResourceManager+SOGo.h>
#import <UI/Common/WODirectAction+SOGo.h>
#import <UI/MailPartViewers/UIxMailSizeFormatter.h> #import <UI/MailPartViewers/UIxMailSizeFormatter.h>
#import "WOContext+UIxMailer.h" #import "WOContext+UIxMailer.h"

View File

@ -1,6 +1,6 @@
/* UIxMailSourceView.h - this file is part of SOGo /* UIxMailSourceView.h - this file is part of SOGo
* *
* Copyright (C) 2007-2015 Inverse inc. * Copyright (C) 2007-2016 Inverse inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -21,8 +21,9 @@
#ifndef UIXMAILSOURCEVIEW_H #ifndef UIXMAILSOURCEVIEW_H
#define UIXMAILSOURCEVIEW_H #define UIXMAILSOURCEVIEW_H
#import <UI/Common/SOGoDirectAction.h>
@interface UIxMailSourceView : WODirectAction @interface UIxMailSourceView : SOGoDirectAction
@end @end

View File

@ -1,6 +1,6 @@
/* UIxMailSourceView.m - this file is part of SOGo /* UIxMailSourceView.m - this file is part of SOGo
* *
* Copyright (C) 2007-2015 Inverse inc. * Copyright (C) 2007-2016 Inverse inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -23,8 +23,6 @@
#import <SoObjects/Mailer/SOGoMailObject.h> #import <SoObjects/Mailer/SOGoMailObject.h>
#import <UI/Common/WODirectAction+SOGo.h>
#import "UIxMailSourceView.h" #import "UIxMailSourceView.h"
@implementation UIxMailSourceView @implementation UIxMailSourceView

View File

@ -1,5 +1,5 @@
/* /*
Copyright (C) 2014 Inverse inc. Copyright (C) 2014-2016 Inverse inc.
This file is part of SOGo. This file is part of SOGo.
@ -23,10 +23,11 @@
#import <SOGo/SOGoCache.h> #import <SOGo/SOGoCache.h>
#import <SOGo/NSObject+Utilities.h> #import <SOGo/NSObject+Utilities.h>
#import <NGObjWeb/NSException+HTTP.h>
#import <NGObjWeb/WOContext.h> #import <NGObjWeb/WOContext.h>
#import <NGObjWeb/WODirectAction.h>
#import <NGObjWeb/NSException+HTTP.h>
#import <NGObjWeb/WOResponse.h>
#import <Common/WODirectAction+SOGo.h>
#import <ActiveSync/SOGoActiveSyncDispatcher.h> #import <ActiveSync/SOGoActiveSyncDispatcher.h>
@interface SOGoMicrosoftActiveSyncActions : WODirectAction @interface SOGoMicrosoftActiveSyncActions : WODirectAction
@ -47,7 +48,9 @@
Class clazz; Class clazz;
request = (WORequest *)[context request]; request = (WORequest *)[context request];
response = [self responseWithStatus: 200]; response = [context response];
[response setStatus: 200];
[response setHeader: @"text/plain; charset=utf-8" forKey: @"content-type"];
bundle = [NSBundle bundleForClass: NSClassFromString(@"ActiveSyncProduct")]; bundle = [NSBundle bundleForClass: NSClassFromString(@"ActiveSyncProduct")];
clazz = [bundle classNamed: @"SOGoActiveSyncDispatcher"]; clazz = [bundle classNamed: @"SOGoActiveSyncDispatcher"];

View File

@ -36,6 +36,7 @@
#import <Appointments/SOGoAppointmentFolders.h> #import <Appointments/SOGoAppointmentFolders.h>
#import <SOGo/NSString+Crypto.h>
#import <SOGo/NSString+Utilities.h> #import <SOGo/NSString+Utilities.h>
#import <SOGo/SOGoBuild.h> #import <SOGo/SOGoBuild.h>
#import <SOGo/SOGoCache.h> #import <SOGo/SOGoCache.h>
@ -170,14 +171,14 @@
{ {
WOResponse *response; WOResponse *response;
WORequest *request; WORequest *request;
WOCookie *authCookie; WOCookie *authCookie, *xsrfCookie;
SOGoWebAuthenticator *auth; SOGoWebAuthenticator *auth;
SOGoAppointmentFolders *calendars; SOGoAppointmentFolders *calendars;
SOGoUserDefaults *ud; SOGoUserDefaults *ud;
SOGoUser *loggedInUser; SOGoUser *loggedInUser;
NSDictionary *params; NSDictionary *params;
NSString *username, *password, *language, *domain, *remoteHost; NSString *username, *password, *language, *domain, *remoteHost;
NSArray *supportedLanguages; NSArray *supportedLanguages, *creds;
SOGoPasswordPolicyError err; SOGoPasswordPolicyError err;
int expire, grace; int expire, grace;
@ -232,6 +233,13 @@
inContext: context]; inContext: context];
[response addCookie: authCookie]; [response addCookie: authCookie];
// We prepare the XSRF protection cookie
creds = [auth parseCredentials: [authCookie value]];
xsrfCookie = [WOCookie cookieWithName: @"XSRF-TOKEN"
value: [[SOGoSession valueForSessionKey: [creds lastObject]] asSHA1String]];
[xsrfCookie setPath: [NSString stringWithFormat: @"/%@/", [[context request] applicationName]]];
[response addCookie: xsrfCookie];
supportedLanguages = [[SOGoSystemDefaults sharedSystemDefaults] supportedLanguages = [[SOGoSystemDefaults sharedSystemDefaults]
supportedLanguages]; supportedLanguages];
loggedInUser = [SOGoUser userWithLogin: username]; loggedInUser = [SOGoUser userWithLogin: username];
@ -540,8 +548,8 @@
- (WOResponse *) changePasswordAction - (WOResponse *) changePasswordAction
{ {
NSString *username, *domain, *password, *newPassword, *value; NSString *username, *domain, *password, *newPassword, *value;
WOCookie *authCookie, *xsrfCookie;
NSDictionary *message; NSDictionary *message;
WOCookie *authCookie;
NSArray *creds; NSArray *creds;
SOGoUserManager *um; SOGoUserManager *um;
SOGoPasswordPolicyError error; SOGoPasswordPolicyError error;
@ -592,6 +600,12 @@
andPassword: newPassword andPassword: newPassword
inContext: context]; inContext: context];
[response addCookie: authCookie]; [response addCookie: authCookie];
// We update the XSRF protection cookie
creds = [auth parseCredentials: [authCookie value]];
xsrfCookie = [WOCookie cookieWithName: @"XSRF-TOKEN"
value: [[SOGoSession valueForSessionKey: [creds lastObject]] asSHA1String]];
[response addCookie: xsrfCookie];
} }
else else
response = [self _responseWithLDAPPolicyError: error]; response = [self _responseWithLDAPPolicyError: error];

View File

@ -455,8 +455,8 @@
- (id <WOActionResults>) logoffAction - (id <WOActionResults>) logoffAction
{ {
SOGoWebAuthenticator *auth;
NSString *userName, *value; NSString *userName, *value;
SOGoWebAuthenticator *auth;
WOResponse *response; WOResponse *response;
NSCalendarDate *date; NSCalendarDate *date;
WOCookie *cookie; WOCookie *cookie;
@ -486,6 +486,12 @@
if (cookie) if (cookie)
[response addCookie: cookie]; [response addCookie: cookie];
// We remove the XSRF cookie
cookie = [WOCookie cookieWithName: @"XSRF-TOKEN" value: @"discard"];
[cookie setPath: [NSString stringWithFormat: @"/%@/", [[context request] applicationName]]];
[cookie setExpires: [date yesterday]];
[response addCookie: cookie];
[response setHeader: [date rfc822DateString] forKey: @"Last-Modified"]; [response setHeader: [date rfc822DateString] forKey: @"Last-Modified"];
[response setHeader: @"no-store, no-cache, must-revalidate," [response setHeader: @"no-store, no-cache, must-revalidate,"
@" max-age=0, post-check=0, pre-check=0" @" max-age=0, post-check=0, pre-check=0"

View File

@ -1,6 +1,6 @@
/* UIxJSONPreferences.h - this file is part of SOGo /* UIxJSONPreferences.h - this file is part of SOGo
* *
* Copyright (C) 2007-2015 Inverse inc. * Copyright (C) 2007-2016 Inverse inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -21,8 +21,9 @@
#ifndef UIXJSONPREFERENCES_H #ifndef UIXJSONPREFERENCES_H
#define UIXJSONPREFERENCES_H #define UIXJSONPREFERENCES_H
#import <UI/Common/SOGoDirectAction.h>
@interface UIxJSONPreferences : WODirectAction @interface UIxJSONPreferences : SOGoDirectAction
@end @end

View File

@ -35,8 +35,6 @@
#import <SOGo/WOResourceManager+SOGo.h> #import <SOGo/WOResourceManager+SOGo.h>
#import <Mailer/SOGoMailLabel.h> #import <Mailer/SOGoMailLabel.h>
#import <UI/Common/WODirectAction+SOGo.h>
#import "UIxJSONPreferences.h" #import "UIxJSONPreferences.h"
static SoProduct *preferencesProduct = nil; static SoProduct *preferencesProduct = nil;

View File

@ -34,11 +34,14 @@
#import <SOGo/NSCalendarDate+SOGo.h> #import <SOGo/NSCalendarDate+SOGo.h>
#import <SOGo/NSDictionary+Utilities.h> #import <SOGo/NSDictionary+Utilities.h>
#import <SOGo/NSObject+Utilities.h> #import <SOGo/NSObject+Utilities.h>
#import <SOGo/NSString+Crypto.h>
#import <SOGo/NSString+Utilities.h> #import <SOGo/NSString+Utilities.h>
#import <SOGo/SOGoBuild.h> #import <SOGo/SOGoBuild.h>
#import <SOGo/SOGoSession.h>
#import <SOGo/SOGoSystemDefaults.h> #import <SOGo/SOGoSystemDefaults.h>
#import <SOGo/SOGoUser.h> #import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserFolder.h> #import <SOGo/SOGoUserFolder.h>
#import <SOGo/SOGoWebAuthenticator.h>
#import <SOGo/WOContext+SOGo.h> #import <SOGo/WOContext+SOGo.h>
#import <SOGo/WOResourceManager+SOGo.h> #import <SOGo/WOResourceManager+SOGo.h>
@ -763,4 +766,42 @@ static SoProduct *commonProduct = nil;
return [sd uixDebugEnabled]; return [sd uixDebugEnabled];
} }
//
// Protection against XSRF
//
- (id<WOActionResults>)performActionNamed:(NSString *)_actionName
{
SOGoWebAuthenticator *auth;
NSString *value, *token;
NSArray *creds;
if (![[SOGoSystemDefaults sharedSystemDefaults] xsrfValidationEnabled])
return [super performActionNamed: _actionName];
// If the action is 'connect' (or 'logoff'), we let it go as the token
// needs to be created (or destroyed) during the session initialization
if ([_actionName isEqualToString: @"connect"] ||
[_actionName isEqualToString: @"logoff"])
{
return [super performActionNamed: _actionName];
}
// We grab the X-XSRF-TOKEN header
token = [[context request] headerForKey: @"X-XSRF-TOKEN"];
// We compare it with our session key
auth = [[WOApplication application]
authenticatorInContext: context];
value = [[context request]
cookieValueForKey: [auth cookieNameInContext: context]];
creds = [auth parseCredentials: value];
value = [SOGoSession valueForSessionKey: [creds lastObject]];
if ([token isEqualToString: [value asSHA1String]])
return [super performActionNamed: _actionName];
return nil;
}
@end /* UIxComponent */ @end /* UIxComponent */

View File

@ -21,8 +21,9 @@
#ifndef UIXAPPOINTMENTACTIONS_H #ifndef UIXAPPOINTMENTACTIONS_H
#define UIXAPPOINTMENTACTIONS_H #define UIXAPPOINTMENTACTIONS_H
#import <Common/SOGoDirectAction.h>
@interface UIxAppointmentActions : WODirectAction @interface UIxAppointmentActions : SOGoDirectAction
@end @end

View File

@ -40,8 +40,6 @@
#import <Appointments/SOGoAppointmentFolder.h> #import <Appointments/SOGoAppointmentFolder.h>
#import <Appointments/SOGoAppointmentFolders.h> #import <Appointments/SOGoAppointmentFolders.h>
#import <Common/WODirectAction+SOGo.h>
#import "UIxAppointmentActions.h" #import "UIxAppointmentActions.h"
@implementation UIxAppointmentActions @implementation UIxAppointmentActions

View File

@ -1,6 +1,6 @@
/* UIxCalListingActions.h - this file is part of SOGo /* UIxCalListingActions.h - this file is part of SOGo
* *
* Copyright (C) 2006-2015 Inverse inc. * Copyright (C) 2006-2016 Inverse inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -21,7 +21,7 @@
#ifndef UIXCALLISTINGACTIONVIEW_H #ifndef UIXCALLISTINGACTIONVIEW_H
#define UIXCALLISTINGACTIONVIEW_H #define UIXCALLISTINGACTIONVIEW_H
#import <Common/WODirectAction+SOGo.h> #import <Common/SOGoDirectAction.h>
@class NSCalendarDate; @class NSCalendarDate;
@class NSMutableDictionary; @class NSMutableDictionary;
@ -33,7 +33,7 @@
@class WOResponse; @class WOResponse;
@class WORequest; @class WORequest;
@interface UIxCalListingActions : WODirectAction @interface UIxCalListingActions : SOGoDirectAction
{ {
NSMutableDictionary *componentsData; NSMutableDictionary *componentsData;
NSCalendarDate *startDate; NSCalendarDate *startDate;

View File

@ -47,8 +47,6 @@
#import <Appointments/SOGoAppointmentFolders.h> #import <Appointments/SOGoAppointmentFolders.h>
#import <Appointments/SOGoWebAppointmentFolder.h> #import <Appointments/SOGoWebAppointmentFolder.h>
#import <UI/Common/WODirectAction+SOGo.h>
#import "NSArray+Scheduler.h" #import "NSArray+Scheduler.h"
#import "UIxCalListingActions.h" #import "UIxCalListingActions.h"
@ -638,7 +636,7 @@ static NSArray *tasksFields = nil;
NSDictionary *data; NSDictionary *data;
NSEnumerator *folders; NSEnumerator *folders;
unsigned int browserTime, laterTime; unsigned int browserTime, laterTime;
// We look for alarms in the next 48 hours // We look for alarms in the next 48 hours
browserTime = [[[context request] formValueForKey: @"browserTime"] intValue]; browserTime = [[[context request] formValueForKey: @"browserTime"] intValue];
laterTime = browserTime + 60*60*48; laterTime = browserTime + 60*60*48;
@ -779,7 +777,7 @@ static NSArray *tasksFields = nil;
unsigned int interval; unsigned int interval;
BOOL isAllDay; BOOL isAllDay;
NSString *sort, *ascending; NSString *sort, *ascending;
[self _setupContext]; [self _setupContext];
[self saveFilterValue: @"EventsFilterState"]; [self saveFilterValue: @"EventsFilterState"];
[self saveSortValue: @"EventsSortingState"]; [self saveSortValue: @"EventsSortingState"];
@ -1317,7 +1315,7 @@ _computeBlocksPosition (NSArray *blocks)
NSString *calendarName, *calendarId; NSString *calendarName, *calendarId;
BOOL isAllDay; BOOL isAllDay;
int i, j; int i, j;
[self _setupContext]; [self _setupContext];
events = [self _fetchFields: eventsFields forComponentOfType: @"vevent"]; events = [self _fetchFields: eventsFields forComponentOfType: @"vevent"];
@ -1486,7 +1484,7 @@ _computeBlocksPosition (NSArray *blocks)
int statusCode; int statusCode;
int startSecs; int startSecs;
int endsSecs; int endsSecs;
filteredTasks = [NSMutableArray array]; filteredTasks = [NSMutableArray array];
[self _setupContext]; [self _setupContext];
@ -1573,9 +1571,8 @@ _computeBlocksPosition (NSArray *blocks)
SOGoAppointmentFolder *folder; SOGoAppointmentFolder *folder;
SOGoAppointmentFolders *co; SOGoAppointmentFolders *co;
NSArray *folders; NSArray *folders;
int i; int i;
co = [self clientObject]; co = [self clientObject];
folders = [co subFolders]; folders = [co subFolders];
activeTasksByCalendars = [NSMutableDictionary dictionaryWithCapacity: [folders count]]; activeTasksByCalendars = [NSMutableDictionary dictionaryWithCapacity: [folders count]];

View File

@ -1,6 +1,6 @@
/* UIxCalMainActions.h - this file is part of SOGo /* UIxCalMainActions.h - this file is part of SOGo
* *
* Copyright (C) 2009-2013 Inverse inc. * Copyright (C) 2009-2016 Inverse inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -21,9 +21,9 @@
#ifndef UIXCALMAINACTIONS_H #ifndef UIXCALMAINACTIONS_H
#define UIXCALMAINACTIONS_H #define UIXCALMAINACTIONS_H
#import <Common/WODirectAction+SOGo.h> #import <Common/SOGoDirectAction.h>
@interface UIxCalMainActions : WODirectAction @interface UIxCalMainActions : SOGoDirectAction
@end @end

View File

@ -1,6 +1,6 @@
/* UIxCalMainActions.m - this file is part of SOGo /* UIxCalMainActions.m - this file is part of SOGo
* *
* Copyright (C) 2009-2015 Inverse inc. * Copyright (C) 2009-2016 Inverse inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

View File

@ -151,11 +151,17 @@
changePassword: function(newPassword) { changePassword: function(newPassword) {
var d = $q.defer(), var d = $q.defer(),
loginCookie = readLoginCookie(); loginCookie = readLoginCookie(),
xsrfCookie = $cookies.get('XSRF-TOKEN');
$cookies.remove('XSRF-TOKEN', {path: '/SOGo/'});
$http({ $http({
method: 'POST', method: 'POST',
url: '/SOGo/so/changePassword', url: '/SOGo/so/changePassword',
headers: {
'X-XSRF-TOKEN' : xsrfCookie
},
data: { data: {
userName: loginCookie[0], userName: loginCookie[0],
password: loginCookie[1], password: loginCookie[1],
@ -186,6 +192,8 @@
perr = passwordPolicyConfig.PolicyPasswordUnknown; perr = passwordPolicyConfig.PolicyPasswordUnknown;
} }
// Restore the cookie
$cookies.put('XSRF-TOKEN', xsrfCookie, {path: '/SOGo/'});
d.reject(error); d.reject(error);
}); });
return d.promise; return d.promise;