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> 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 * Main/SOGo.m (-davURLAsString): we ensure that the url ends with
"/" since the /SOGo object is a collection and the caller may rely "/" since the /SOGo object is a collection and the caller may rely
on this. on this.

View File

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

View File

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

View File

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

View File

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

View File

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