Monotone-Parent: 5f1640d17dbc95901d131c16f8d4499aa044594c

Monotone-Revision: 0bbbd12ea5011c00d28bdc2f4c9377a886d244e0

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2009-12-08T23:18:12
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2009-12-08 23:18:12 +00:00
parent e361b6615f
commit af7f0ba0e4
6 changed files with 92 additions and 25 deletions

View File

@ -1,5 +1,17 @@
2009-12-08 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* Main/SOGo.m (-lookupName:inContext:acquire:): ensure the web
access is enabled or the request is a DAV request before
proceeding.
* SoObjects/SOGo/SOGoUserFolder.m (-toManyRelationShipKeys)
(-fetchContentObjectNames): ensure the proper dav access is
enabled in order before listing the related objects.
* SoObjects/SOGo/SOGoSystemDefaults.m (-isWebAccessEnabled)
(-isCalendarDAVAccessEnabled, isAddressBookDAVAccessEnabled): new
self-explanatory accessors.
* Main/SOGo.m (-davURLAsString): we ensure that the url ends with
"/" since the /SOGo object is a collection and the caller may rely
on this.

View File

@ -33,7 +33,7 @@
#import <NGObjWeb/SoClassSecurityInfo.h>
#import <NGObjWeb/WOContext.h>
#import <NGObjWeb/WORequest.h>
#import <NGObjWeb/WORequest+So.h>
#import <NGExtensions/NGBundleManager.h>
#import <NGExtensions/NSNull+misc.h>
@ -311,28 +311,35 @@ static BOOL debugLeaks;
acquire: (BOOL) _flag
{
id obj;
SOGoSystemDefaults *sd;
/* put locale info into the context in case it's not there */
[self _setupLocaleInContext:_ctx];
/* first check attributes directly bound to the application */
obj = [super lookupName:_key inContext:_ctx acquire:_flag];
if (!obj)
sd = [SOGoSystemDefaults sharedSystemDefaults];
if ([sd isWebAccessEnabled] || [[_ctx request] isSoWebDAVRequest])
{
/*
The problem is, that at this point we still get request for resources,
eg 'favicon.ico'.
Addition: we also get queries for various other methods, like "GET" if
no method was provided in the query path.
*/
/* first check attributes directly bound to the application */
obj = [super lookupName:_key inContext:_ctx acquire:_flag];
if (!obj)
{
/*
The problem is, that at this point we still get request for
resources, eg 'favicon.ico'.
Addition: we also get queries for various other methods, like
"GET" if no method was provided in the query path.
*/
if (![_key isEqualToString:@"favicon.ico"])
{
if ([self isUserName: _key inContext: _ctx])
obj = [self lookupUser: _key inContext: _ctx];
}
if (![_key isEqualToString:@"favicon.ico"])
{
if ([self isUserName: _key inContext: _ctx])
obj = [self lookupUser: _key inContext: _ctx];
}
}
}
else
obj = nil;
return obj;
}

View File

@ -22,6 +22,10 @@
SOGoSMTPServer = "localhost";
SOGoMailSpoolPath = "/tmp";
SOGoWebAccessEnabled = YES;
SOGoCalendarDAVAccessEnabled = YES;
SOGoAddressBookDAVAccessEnabled = YES;
SOGoLoginModule = "Mail";
SOGoLanguage = "English";
SOGoSupportedLanguages = ( "Czech", "Welsh", "English", "Spanish",

View File

@ -38,6 +38,10 @@
- (BOOL) trustProxyAuthentication;
- (BOOL) useRelativeURLs;
- (BOOL) isWebAccessEnabled;
- (BOOL) isCalendarDAVAccessEnabled;
- (BOOL) isAddressBookDAVAccessEnabled;
- (NSString *) faviconRelativeURL;
- (NSString *) zipPath;
- (int) port;

View File

@ -205,6 +205,21 @@ BootstrapNSUserDefaults ()
return [self boolForKey: @"WOUseRelativeURLs"];
}
- (BOOL) isWebAccessEnabled
{
return [self boolForKey: @"SOGoWebAccessEnabled"];
}
- (BOOL) isCalendarDAVAccessEnabled
{
return [self boolForKey: @"SOGoCalendarDAVAccessEnabled"];
}
- (BOOL) isAddressBookDAVAccessEnabled
{
return [self boolForKey: @"SOGoAddressBookDAVAccessEnabled"];
}
- (NSString *) faviconRelativeURL
{
return [self stringForKey: @"SOGoFaviconRelativeURL"];

View File

@ -31,6 +31,7 @@
#import <NGObjWeb/WOApplication.h>
#import <NGObjWeb/WOContext+SoObjects.h>
#import <NGObjWeb/WORequest.h>
#import <NGObjWeb/WORequest+So.h>
#import <NGObjWeb/WOResponse.h>
#import <NGExtensions/NSObject+Logs.h>
@ -53,6 +54,7 @@
#import "NSDictionary+Utilities.h"
#import "SOGoUserManager.h"
#import "SOGoPermissions.h"
#import "SOGoSystemDefaults.h"
#import "SOGoUser.h"
#import "WORequest+SOGo.h"
@ -66,11 +68,16 @@
{
NSMutableArray *children;
SOGoUser *currentUser;
BOOL isDAVRequest;
SOGoSystemDefaults *sd;
children = [NSMutableArray arrayWithCapacity: 4];
sd = [SOGoSystemDefaults sharedSystemDefaults];
isDAVRequest = [[context request] isSoWebDAVRequest];
currentUser = [context activeUser];
if ([currentUser canAccessModule: @"Calendar"])
if ((!isDAVRequest || [sd isCalendarDAVAccessEnabled])
&& [currentUser canAccessModule: @"Calendar"])
{
[children addObject: @"Calendar"];
/* support for caldav-proxy, which is currently limited to iCal but may
@ -82,7 +89,8 @@
[children addObject: @"calendar-proxy-read"];
}
}
[children addObject: @"Contacts"];
if (isDAVRequest && [sd isAddressBookDAVAccessEnabled])
[children addObject: @"Contacts"];
if ([currentUser canAccessModule: @"Mail"])
[children addObject: @"Mail"];
// [children addObject: @"Preferences"];
@ -543,15 +551,20 @@
inContext: (WOContext *) _ctx
acquire: (BOOL) _flag
{
id obj;
SOGoUser *currentUser;
BOOL isDAVRequest;
SOGoSystemDefaults *sd;
id obj;
/* first check attributes directly bound to the application */
obj = [super lookupName: _key inContext: _ctx acquire: NO];
if (!obj)
{
sd = [SOGoSystemDefaults sharedSystemDefaults];
isDAVRequest = [[context request] isSoWebDAVRequest];
currentUser = [_ctx activeUser];
if ([currentUser canAccessModule: @"Calendar"])
if ((!isDAVRequest || [sd isCalendarDAVAccessEnabled])
&& [currentUser canAccessModule: @"Calendar"])
{
if ([_key isEqualToString: @"Calendar"])
obj = [self privateCalendars: @"Calendar" inContext: _ctx];
@ -568,7 +581,9 @@
&& [currentUser canAccessModule: @"Mail"])
obj = [self mailAccountsFolder: _key inContext: _ctx];
if (!obj && [_key isEqualToString: @"Contacts"])
if (!obj
&& [_key isEqualToString: @"Contacts"]
&& (isDAVRequest && [sd isAddressBookDAVAccessEnabled]))
obj = [self privateContacts: _key inContext: _ctx];
// else if ([_key isEqualToString: @"Preferences"])
@ -586,10 +601,20 @@
- (NSArray *) fetchContentObjectNames
{
SOGoSystemDefaults *sd;
SOGoUser *currentUser;
static NSArray *cos = nil;
if (!cos)
cos = [[NSArray alloc] initWithObjects: @"freebusy.ifb", nil];
sd = [SOGoSystemDefaults sharedSystemDefaults];
currentUser = [context activeUser];
if ((![[context request] isSoWebDAVRequest] || [sd isCalendarDAVAccessEnabled])
&& [currentUser canAccessModule: @"Calendar"])
{
if (!cos)
cos = [[NSArray alloc] initWithObjects: @"freebusy.ifb", nil];
}
else
cos = [NSArray array];
return cos;
}