From 13df91ba79a1156f07b811473b126457d973f57d Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 2 Jun 2010 16:35:59 +0000 Subject: [PATCH] Monotone-Parent: 4ac4ae3613d51d31b8aa0f22e8581e25651b89fd Monotone-Revision: 1ab4cc7bd955a40f41ed5d3e29deca4ff763777b Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-06-02T16:35:59 Monotone-Branch: ca.inverse.sogo --- Main/SOGo.m | 21 +++++++---- SoObjects/Appointments/product.plist | 4 +-- SoObjects/SOGo/SOGoObject.h | 3 ++ SoObjects/SOGo/SOGoObject.m | 9 +++++ SoObjects/SOGo/SOGoPublicBaseFolder.h | 31 +++++++++++++++++ SoObjects/SOGo/SOGoPublicBaseFolder.m | 50 +++++++++++++++++++++++++++ SoObjects/SOGo/SOGoUser.m | 3 ++ SoObjects/SOGo/SOGoWebAuthenticator.m | 2 +- UI/MainUI/product.plist | 21 +++++++---- 9 files changed, 129 insertions(+), 15 deletions(-) create mode 100644 SoObjects/SOGo/SOGoPublicBaseFolder.h create mode 100644 SoObjects/SOGo/SOGoPublicBaseFolder.m diff --git a/Main/SOGo.m b/Main/SOGo.m index 817eb395e..78b884745 100644 --- a/Main/SOGo.m +++ b/Main/SOGo.m @@ -49,6 +49,7 @@ #import #import #import +#import #import #import #import @@ -305,18 +306,21 @@ static BOOL debugLeaks; id obj; WORequest *request; BOOL isDAVRequest; + SOGoSystemDefaults *sd; /* put locale info into the context in case it's not there */ [self _setupLocaleInContext:_ctx]; + sd = [SOGoSystemDefaults sharedSystemDefaults]; request = [_ctx request]; - isDAVRequest = [request isSoWebDAVRequest]; - if (isDAVRequest - || [[SOGoSystemDefaults sharedSystemDefaults] isWebAccessEnabled]) + isDAVRequest = [[request requestHandlerKey] isEqualToString:@"dav"]; + if (isDAVRequest || [sd isWebAccessEnabled]) { if (isDAVRequest) { - if ([[request method] isEqualToString: @"REPORT"]) + if ([_key isEqualToString: @"public"] && [sd enablePublicAccess]) + obj = [SOGoPublicBaseFolder objectWithName: @"public" inContainer: self]; + else if ([[request method] isEqualToString: @"REPORT"]) obj = [self davReportInvocationForKey: _key]; else obj = nil; @@ -326,6 +330,7 @@ static BOOL debugLeaks; /* first check attributes directly bound to the application */ obj = [super lookupName:_key inContext:_ctx acquire:_flag]; } + if (!obj) { /* @@ -335,7 +340,6 @@ static BOOL debugLeaks; Addition: we also get queries for various other methods, like "GET" if no method was provided in the query path. */ - if ([_key length] > 0 && ![_key isEqualToString:@"favicon.ico"]) obj = [self lookupUser: _key inContext: _ctx]; } @@ -346,6 +350,11 @@ static BOOL debugLeaks; return obj; } +- (BOOL) isInPublicZone +{ + return NO; +} + /* WebDAV */ - (NSString *) davDisplayName @@ -422,7 +431,7 @@ static BOOL debugLeaks; [self logWithFormat: @"request took %f seconds to execute", timeDelta]; [resp setHeader: [NSString stringWithFormat: @"%f", timeDelta] - forKey: @"SOGoRequestDuration"]; + forKey: @"SOGo-Request-Duration"]; } if (![self isTerminating]) diff --git a/SoObjects/Appointments/product.plist b/SoObjects/Appointments/product.plist index 22df3dfcd..865942b97 100644 --- a/SoObjects/Appointments/product.plist +++ b/SoObjects/Appointments/product.plist @@ -100,8 +100,8 @@ superclass = "SOGoContentObject"; protectedBy = "Access Contents Information"; defaultRoles = { - "Access Contents Information" = ( "Owner", "Authenticated" ); - "WebDAV Access" = ( "Owner", "Authenticated" ); + "Access Contents Information" = ( "Owner", "Authenticated", "PublicUser" ); + "WebDAV Access" = ( "Owner", "Authenticated", "PublicUser" ); }; }; }; diff --git a/SoObjects/SOGo/SOGoObject.h b/SoObjects/SOGo/SOGoObject.h index 82bb0cfc2..2daaa8abb 100644 --- a/SoObjects/SOGo/SOGoObject.h +++ b/SoObjects/SOGo/SOGoObject.h @@ -68,6 +68,7 @@ SOGoWebDAVAclManager *webdavAclManager; id container; BOOL activeUserIsOwner; + BOOL isInPublicZone; } + (NSString *) globallyUniqueObjectId; @@ -79,6 +80,8 @@ + (SOGoWebDAVAclManager *) webdavAclManager; +- (BOOL) isInPublicZone; + /* accessors */ - (NSString *) nameInContainer; diff --git a/SoObjects/SOGo/SOGoObject.m b/SoObjects/SOGo/SOGoObject.m index 06b4ce34f..da6547c84 100644 --- a/SoObjects/SOGo/SOGoObject.m +++ b/SoObjects/SOGo/SOGoObject.m @@ -166,6 +166,7 @@ owner = nil; webdavAclManager = [[self class] webdavAclManager]; activeUserIsOwner = NO; + isInPublicZone = NO; } return self; @@ -228,6 +229,14 @@ return owner; } +- (BOOL) isInPublicZone +{ + if (!isInPublicZone) + isInPublicZone = [container isInPublicZone]; + + return isInPublicZone; +} + /* hierarchy */ - (NSArray *) fetchSubfolders diff --git a/SoObjects/SOGo/SOGoPublicBaseFolder.h b/SoObjects/SOGo/SOGoPublicBaseFolder.h new file mode 100644 index 000000000..e75221936 --- /dev/null +++ b/SoObjects/SOGo/SOGoPublicBaseFolder.h @@ -0,0 +1,31 @@ +/* SOGoPublicBaseFolder.h - this file is part of SOGo + * + * Copyright (C) 2010 Inverse inc. + * + * Author: Wolfgang Sourdeau + * + * 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 + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef SOGOPUBLICBASEFOLDER_H +#define SOGOPUBLICBASEFOLDER_H + +#import "SOGoFolder.h" + +@interface SOGoPublicBaseFolder : SOGoFolder +@end + +#endif /* SOGOPUBLICBASEFOLDER_H */ diff --git a/SoObjects/SOGo/SOGoPublicBaseFolder.m b/SoObjects/SOGo/SOGoPublicBaseFolder.m new file mode 100644 index 000000000..7f9c7a33e --- /dev/null +++ b/SoObjects/SOGo/SOGoPublicBaseFolder.m @@ -0,0 +1,50 @@ +/* SOGoPublicBaseFolder.m - this file is part of SOGo + * + * Copyright (C) 2010 Inverse inc. + * + * Author: Wolfgang Sourdeau + * + * 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 + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#import + +#import "SOGoUser.h" + +#import "SOGoPublicBaseFolder.h" + +@implementation SOGoPublicBaseFolder + +- (id) lookupName: (NSString *) key + inContext: (id) localContext + acquire: (BOOL) acquire +{ + id userFolder; + + if ([key length] > 0 && [SOGoUser userWithLogin: key roles: nil]) + userFolder = [SOGoUserFolder objectWithName: key inContainer: self]; + else + userFolder = nil; + + return userFolder; +} + +- (BOOL) isInPublicZone +{ + return YES; +} + +@end diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index 88be4c5b6..9d124b7c1 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -650,6 +650,9 @@ sogoRoles = [(SOGoObject *) object subscriptionRoles]; if ([sogoRoles firstObjectCommonWithArray: rolesForObject]) [rolesForObject addObject: SOGoRole_AuthorizedSubscriber]; + if ([login isEqualToString: @"anonymous"] + && [(SOGoObject *) object isInPublicZone]) + [rolesForObject addObject: SOGoRole_PublicUser]; } #warning this is a hack to work-around the poor implementation of PROPPATCH in SOPE diff --git a/SoObjects/SOGo/SOGoWebAuthenticator.m b/SoObjects/SOGo/SOGoWebAuthenticator.m index a5eea8f82..70d9a71f0 100644 --- a/SoObjects/SOGo/SOGoWebAuthenticator.m +++ b/SoObjects/SOGo/SOGoWebAuthenticator.m @@ -110,7 +110,7 @@ SOGoUser *user; user = (SOGoUser *) [super userInContext: _ctx]; - if (!user) + if (!user || [[user login] isEqualToString: @"anonymous"]) { if (!anonymous) anonymous = [[SOGoUser alloc] diff --git a/UI/MainUI/product.plist b/UI/MainUI/product.plist index 578b3e109..7bb31f229 100644 --- a/UI/MainUI/product.plist +++ b/UI/MainUI/product.plist @@ -11,7 +11,7 @@ superclass = "SoComponent"; protectedBy = ""; defaultRoles = { - "View" = ( "Authenticated" ); + "View" = ( "Authenticated", "PublicUser" ); }; }; SOGoObject = { @@ -67,10 +67,10 @@ }; SOGoParentFolder = { superclass = "SOGoFolder"; - protectedBy = "Access Contents Information"; + protectedBy = ""; defaultRoles = { - "Access Contents Information" = ( "Authenticated" ); - "WebDAV Access" = ( "Authenticated" ); + "Access Contents Information" = ( "Authenticated", "PublicUser" ); + "WebDAV Access" = ( "Authenticated", "PublicUser" ); "Add Folders" = ( "Owner" ); }; }; @@ -78,14 +78,23 @@ superclass = "SOGoFolder"; protectedBy = "Access Contents Information"; defaultRoles = { - "Access Contents Information" = ( "Authenticated" ); - "WebDAV Access" = ( "Authenticated" ); + "Access Contents Information" = ( "Authenticated", "PublicUser" ); + "WebDAV Access" = ( "Authenticated", "PublicUser" ); "View" = ( "Authenticated" ); }; }; SOGoGCSFolder = { superclass = "SOGoFolder"; }; + SOGoPublicBaseFolder = { + superclass = "SOGoFolder"; + protectedBy = "Access Contents Information"; + defaultRoles = { + "Access Contents Information" = ( "Authenticated", "PublicUser" ); + "WebDAV Access" = ( "Authenticated", "PublicUser" ); + "View" = ( "Authenticated" ); + }; + }; }; categories = {