def accessControlList(self, request, *args, **kwargs): """ Override this to give write proxies DAV:write-acl privilege so they can add attachments too. """ acl = (yield super(DropBoxHomeResource, self).accessControlList(request, *args, **kwargs)) if config.EnableProxyPrincipals: owner = (yield self.ownerPrincipal(request)) newaces = tuple(acl.children) newaces += ( # DAV:write-acl access for this principal's calendar-proxy-write users. davxml.ACE( davxml.Principal( davxml.HRef( joinURL(owner.principalURL(), "calendar-proxy-write/"))), davxml.Grant(davxml.Privilege(davxml.WriteACL()), ), davxml.Protected(), TwistedACLInheritable(), ), ) returnValue(davxml.ACL(*newaces)) else: returnValue(acl)
def http_ACL(self, request): """ Respond to a ACL request. (RFC 3744, section 8.1) """ if not self.exists(): log.error("File not found: %s" % (self,)) yield responsecode.NOT_FOUND return # # Check authentication and access controls # x = waitForDeferred(self.authorize(request, (davxml.WriteACL(),))) yield x x.getResult() # # Read request body # doc = waitForDeferred(davXMLFromStream(request.stream)) yield doc try: doc = doc.getResult() except ValueError, e: log.error("Error while handling ACL body: %s" % (e,)) raise HTTPError(StatusResponse(responsecode.BAD_REQUEST, str(e)))
def test_Privilege_isAggregateOf(self): """ Privilege.isAggregateOf() """ for a, b in ( (davxml.All(), davxml.Write()), (davxml.All(), davxml.ReadACL()), (davxml.Write(), davxml.WriteProperties()), (davxml.Write(), davxml.WriteContent()), (davxml.Write(), davxml.Bind()), (davxml.Write(), davxml.Unbind()), ): pa = davxml.Privilege(a) pb = davxml.Privilege(b) self.failUnless(pa.isAggregateOf(pb, davPrivilegeSet), "%s contains %s" % (a.sname(), b.sname())) self.failIf(pb.isAggregateOf(pa, davPrivilegeSet), "%s does not contain %s" % (b.sname(), a.sname())) for a, b in ( (davxml.Unlock(), davxml.Write()), (davxml.Unlock(), davxml.WriteACL()), (davxml.ReadCurrentUserPrivilegeSet(), davxml.WriteProperties()), ): pa = davxml.Privilege(a) pb = davxml.Privilege(b) self.failIf(pb.isAggregateOf(pa, davPrivilegeSet), "%s does not contain %s" % (b.sname(), a.sname()))