Monotone-Parent: 4ac4ae3613d51d31b8aa0f22e8581e25651b89fd

Monotone-Revision: 1ab4cc7bd955a40f41ed5d3e29deca4ff763777b

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2010-06-02T16:35:59
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2010-06-02 16:35:59 +00:00
parent 26cb2290ac
commit 13df91ba79
9 changed files with 129 additions and 15 deletions

View File

@ -49,6 +49,7 @@
#import <SOGo/SOGoCache.h>
#import <SOGo/SOGoDAVAuthenticator.h>
#import <SOGo/SOGoPermissions.h>
#import <SOGo/SOGoPublicBaseFolder.h>
#import <SOGo/SOGoProductLoader.h>
#import <SOGo/SOGoProxyAuthenticator.h>
#import <SOGo/SOGoUserFolder.h>
@ -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])

View File

@ -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" );
};
};
};

View File

@ -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;

View File

@ -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

View File

@ -0,0 +1,31 @@
/* SOGoPublicBaseFolder.h - this file is part of SOGo
*
* Copyright (C) 2010 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
* 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 */

View File

@ -0,0 +1,50 @@
/* SOGoPublicBaseFolder.m - this file is part of SOGo
*
* Copyright (C) 2010 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
* 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 <Foundation/NSString.h>
#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

View File

@ -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

View File

@ -110,7 +110,7 @@
SOGoUser *user;
user = (SOGoUser *) [super userInContext: _ctx];
if (!user)
if (!user || [[user login] isEqualToString: @"anonymous"])
{
if (!anonymous)
anonymous = [[SOGoUser alloc]

View File

@ -11,7 +11,7 @@
superclass = "SoComponent";
protectedBy = "<public>";
defaultRoles = {
"View" = ( "Authenticated" );
"View" = ( "Authenticated", "PublicUser" );
};
};
SOGoObject = {
@ -67,10 +67,10 @@
};
SOGoParentFolder = {
superclass = "SOGoFolder";
protectedBy = "Access Contents Information";
protectedBy = "<public>";
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 = {