[CalendarServer-changes] [13533] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Sat May 24 12:17:44 PDT 2014


Revision: 13533
          http://trac.calendarserver.org//changeset/13533
Author:   sagen at apple.com
Date:     2014-05-24 12:17:43 -0700 (Sat, 24 May 2014)
Log Message:
-----------
Hook up wiki access lookup to AMP

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/directory/principal.py
    CalendarServer/trunk/txdav/dps/client.py
    CalendarServer/trunk/txdav/dps/commands.py
    CalendarServer/trunk/txdav/dps/server.py
    CalendarServer/trunk/txdav/who/wiki.py

Modified: CalendarServer/trunk/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/principal.py	2014-05-22 20:36:32 UTC (rev 13532)
+++ CalendarServer/trunk/twistedcaldav/directory/principal.py	2014-05-24 19:17:43 UTC (rev 13533)
@@ -297,6 +297,7 @@
             self.directory.recordType.location,
             self.directory.recordType.resource,
             self.directory.recordType.address,
+            self.directory.recordType.macOSXServerWiki,
         )
 
         for name, recordType in [

Modified: CalendarServer/trunk/txdav/dps/client.py
===================================================================
--- CalendarServer/trunk/txdav/dps/client.py	2014-05-22 20:36:32 UTC (rev 13532)
+++ CalendarServer/trunk/txdav/dps/client.py	2014-05-24 19:17:43 UTC (rev 13533)
@@ -38,7 +38,8 @@
     RecordsWithRecordTypeCommand, RecordsWithEmailAddressCommand,
     RecordsMatchingTokensCommand, RecordsMatchingFieldsCommand,
     MembersCommand, GroupsCommand, SetMembersCommand,
-    VerifyPlaintextPasswordCommand, VerifyHTTPDigestCommand
+    VerifyPlaintextPasswordCommand, VerifyHTTPDigestCommand,
+    WikiAccessForUID
 )
 from txdav.who.directory import (
     CalendarDirectoryRecordMixin, CalendarDirectoryServiceMixin
@@ -344,7 +345,21 @@
         )
 
 
+    def _convertAccess(self, results):
+        access = results["access"].decode("utf-8")
+        return txdav.who.wiki.WikiAccessLevel.lookupByName(access)
 
+
+    def accessForRecord(self, record):
+        log.debug("DPS Client accessForRecord")
+        return self.service._call(
+            WikiAccessForUID,
+            self._convertAccess,
+            wikiUID=self.uid.encode("utf-8"),
+            uid=record.uid.encode("utf-8")
+        )
+
+
 # Test client:
 
 @inlineCallbacks

Modified: CalendarServer/trunk/txdav/dps/commands.py
===================================================================
--- CalendarServer/trunk/txdav/dps/commands.py	2014-05-22 20:36:32 UTC (rev 13532)
+++ CalendarServer/trunk/txdav/dps/commands.py	2014-05-24 19:17:43 UTC (rev 13533)
@@ -171,3 +171,14 @@
     response = [
         ('authenticated', amp.Boolean()),
     ]
+
+
+
+class WikiAccessForUID(amp.Command):
+    arguments = [
+        ('wikiUID', amp.String()),
+        ('uid', amp.String()),
+    ]
+    response = [
+        ('access', amp.String()),
+    ]

Modified: CalendarServer/trunk/txdav/dps/server.py
===================================================================
--- CalendarServer/trunk/txdav/dps/server.py	2014-05-22 20:36:32 UTC (rev 13532)
+++ CalendarServer/trunk/txdav/dps/server.py	2014-05-24 19:17:43 UTC (rev 13533)
@@ -35,9 +35,11 @@
     RecordsMatchingTokensCommand, RecordsMatchingFieldsCommand,
     MembersCommand, GroupsCommand, SetMembersCommand,
     VerifyPlaintextPasswordCommand, VerifyHTTPDigestCommand,
+    WikiAccessForUID
     # UpdateRecordsCommand, RemoveRecordsCommand
 )
 from txdav.who.util import directoryFromConfig
+from txdav.who.wiki import WikiAccessLevel
 from zope.interface import implementer
 
 
@@ -340,7 +342,24 @@
         returnValue(response)
 
 
+    @WikiAccessForUID.responder
+    @inlineCallbacks
+    def wikiAccessForUID(self, wikiUID, uid):
+        wikiUID = wikiUID.decode("utf-8")
+        uid = uid.decode("utf-8")
+        log.debug("WikiAccessForUID: {w} {u}", w=wikiUID, u=uid)
+        access = WikiAccessLevel.none
+        wikiRecord = (yield self._directory.recordWithUID(wikiUID))
+        userRecord = (yield self._directory.recordWithUID(uid))
+        if wikiRecord is not None and userRecord is not None:
+            access = (yield wikiRecord.accessForRecord(userRecord))
+        response = {
+            "access": access.name.encode("utf-8"),
+        }
+        log.debug("Responding with: {response}", response=response)
+        returnValue(response)
 
+
 class DirectoryProxyAMPFactory(Factory):
     """
     """

Modified: CalendarServer/trunk/txdav/who/wiki.py
===================================================================
--- CalendarServer/trunk/txdav/who/wiki.py	2014-05-22 20:36:32 UTC (rev 13532)
+++ CalendarServer/trunk/txdav/who/wiki.py	2014-05-24 19:17:43 UTC (rev 13533)
@@ -171,11 +171,22 @@
             # once the old API is removed.
             # When we do that note: isn't there a getPage() in twisted.web?
 
+            self.log.debug(
+                "Wiki access check: {wiki}, {user}",
+                wiki=self.shortNames[0],
+                user=uid
+            )
             access = yield accessForUserToWiki(
-                uid, self.shortNames[0],
+                uid.encode("utf-8"), self.shortNames[0].encode("utf-8"),
                 host=self.service.wikiHost,
                 port=self.service.wikiPort,
             )
+            self.log.debug(
+                "Wiki access result: {wiki}, {user}, {access}",
+                wiki=self.shortNames[0],
+                user=uid,
+                access=access,
+            )
 
         except MultiFailure as e:
             self.log.error(
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140524/ef8522d2/attachment.html>


More information about the calendarserver-changes mailing list