[CalendarServer-changes] [3152] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Tue Oct 14 15:42:53 PDT 2008


Revision: 3152
          http://trac.macosforge.org/projects/calendarserver/changeset/3152
Author:   sagen at apple.com
Date:     2008-10-14 15:42:53 -0700 (Tue, 14 Oct 2008)
Log Message:
-----------
Personal calendars can now be accessed by authenticating against wikiserver

Modified Paths:
--------------
    CalendarServer/trunk/conf/caldavd-test.plist
    CalendarServer/trunk/twistedcaldav/config.py
    CalendarServer/trunk/twistedcaldav/root.py

Modified: CalendarServer/trunk/conf/caldavd-test.plist
===================================================================
--- CalendarServer/trunk/conf/caldavd-test.plist	2008-10-14 19:45:36 UTC (rev 3151)
+++ CalendarServer/trunk/conf/caldavd-test.plist	2008-10-14 22:42:53 UTC (rev 3152)
@@ -263,6 +263,19 @@
         <string></string>
       </dict>
 
+      <!-- Wikiserver authentication -->
+      <key>Wiki</key>
+      <dict>
+        <key>Enabled</key>
+        <false/>
+        <key>Cookie</key>
+        <string>sessionID</string>
+        <key>URL</key>
+        <string>http://127.0.0.1/RPC2</string>
+        <key>method</key>
+        <string>userForSession</string>
+      </dict>
+
     </dict>
 
 

Modified: CalendarServer/trunk/twistedcaldav/config.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/config.py	2008-10-14 19:45:36 UTC (rev 3151)
+++ CalendarServer/trunk/twistedcaldav/config.py	2008-10-14 22:42:53 UTC (rev 3152)
@@ -120,6 +120,12 @@
             "Enabled": False,
             "ServicePrincipal": ""
         },
+        "Wiki": {
+            "Enabled": False,
+            "Cookie": "sessionID",
+            "URL": "http://127.0.0.1/RPC2",
+            "method": "userForSession",
+        },
     },
 
     #

Modified: CalendarServer/trunk/twistedcaldav/root.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/root.py	2008-10-14 19:45:36 UTC (rev 3151)
+++ CalendarServer/trunk/twistedcaldav/root.py	2008-10-14 22:42:53 UTC (rev 3152)
@@ -27,6 +27,7 @@
 from twisted.web2.dav import davxml
 from twisted.web2.http import HTTPError, StatusResponse
 from twisted.web2.auth.wrapper import UnauthorizedResponse
+from twisted.web.xmlrpc import Proxy
 
 from twistedcaldav.extensions import DAVFile, CachingXattrPropertyStore, DirectoryPrincipalPropertySearchMixIn
 from twistedcaldav.config import config
@@ -169,6 +170,45 @@
         for filter in self.contentFilters:
             request.addResponseFilter(filter[0], atEnd=filter[1])
 
+
+        # Examine cookies for wiki auth token
+
+        def validSessionID(username):
+            directory = request.site.resource.getDirectory()
+            record = directory.recordWithShortName("users", username)
+            if record is None:
+                raise HTTPError(StatusResponse(
+                    responsecode.FORBIDDEN,
+                    "The username (%s) corresponding to your sessionID was not found by calendar server." % (username,)
+                ))
+            request.authnUser = request.authzUser = davxml.Principal(
+                davxml.HRef.fromString("/principals/__uids__/%s/" % (record.guid,)))
+
+        def invalidSessionID(error):
+            raise HTTPError(StatusResponse(
+                responsecode.FORBIDDEN,
+                "Your sessionID was rejected by the authenticating wiki server."
+            ))
+
+        wikiConfig = config.Authentication["Wiki"]
+        cookies = request.headers.getHeader('cookie')
+        if wikiConfig["Enabled"] and cookies is not None:
+            for cookie in cookies:
+                if cookie.name == wikiConfig["Cookie"]:
+                    token = cookie.value
+                    break
+            else:
+                token = None
+
+            if token is not None:
+                proxy = Proxy(wikiConfig["URL"])
+                d = proxy.callRemote(wikiConfig["method"], token).addCallbacks(
+                    validSessionID, invalidSessionID)
+                d.addCallback(lambda _: super(RootResource, self
+                                              ).locateChild(request, segments))
+                return d
+
+
         if self.useSacls and not hasattr(request, "checkedSACL") and not hasattr(request, "checkingSACL"):
             d = self.checkSacl(request)
             d.addCallback(lambda _: super(RootResource, self
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20081014/9f9ad60e/attachment.html 


More information about the calendarserver-changes mailing list