[CalendarServer-changes] [4320] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Wed Jun 3 17:41:15 PDT 2009
Revision: 4320
http://trac.macosforge.org/projects/calendarserver/changeset/4320
Author: wsanchez at apple.com
Date: 2009-06-03 17:41:15 -0700 (Wed, 03 Jun 2009)
Log Message:
-----------
Re-add X-HTTP-Method-Override patches.
Modified Paths:
--------------
CalendarServer/trunk/lib-patches/Twisted/twisted.web2.auth.digest.patch
CalendarServer/trunk/twistedcaldav/directory/digest.py
Added Paths:
-----------
CalendarServer/trunk/lib-patches/Twisted/twisted.web2.server.patch
Modified: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.auth.digest.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.auth.digest.patch 2009-06-04 00:40:36 UTC (rev 4319)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.auth.digest.patch 2009-06-04 00:41:15 UTC (rev 4320)
@@ -1,22 +1,73 @@
Index: twisted/web2/auth/digest.py
===================================================================
---- twisted/web2/auth/digest.py (revision 26741)
+--- twisted/web2/auth/digest.py (revision 26899)
+++ twisted/web2/auth/digest.py (working copy)
-@@ -158,6 +158,17 @@
- algo, nonce, nc, cnonce, qop, self.method, uri, None
+@@ -138,11 +138,15 @@
+ implements(credentials.IUsernameHashedPassword,
+ IUsernameDigestHash)
+
+- def __init__(self, username, method, realm, fields):
++ def __init__(self, username, method, realm, fields, originalMethod=None):
+ self.username = username
+ self.method = method
+ self.realm = realm
+ self.fields = fields
++ if originalMethod:
++ self.originalMethod = originalMethod
++ else:
++ self.originalMethod = method
+
+ def checkPassword(self, password):
+ response = self.fields.get('response')
+@@ -155,11 +159,23 @@
+
+ expected = calcResponse(
+ calcHA1(algo, self.username, self.realm, password, nonce, cnonce),
+- algo, nonce, nc, cnonce, qop, self.method, uri, None
++ algo, nonce, nc, cnonce, qop, self.originalMethod, uri, None
)
+- return expected == response
+ if expected == response:
+ return True
-+
+
+ # IE7 sends cnonce and nc values, but auth fails if they are used.
+ # So try again without them...
+ # They can be omitted for backwards compatibility [RFC 2069].
-+ expected = calcResponse(
-+ calcHA1(algo, self.username, self.realm, password, nonce, cnonce),
-+ algo, nonce, None, None, qop, self.method, uri, None
-+ )
++ if nc is not None or cnonce is not None:
++ expected = calcResponse(
++ calcHA1(algo, self.username, self.realm, password, nonce, cnonce),
++ algo, nonce, None, None, qop, self.originalMethod, uri, None
++ )
++ if expected == response:
++ return True
+
+ def checkHash(self, digestHash):
+ response = self.fields.get('response')
+ uri = self.fields.get('uri')
+@@ -171,7 +187,7 @@
+
+ expected = calcResponse(
+ calcHA1(algo, None, None, None, nonce, cnonce, preHA1=digestHash),
+- algo, nonce, nc, cnonce, qop, self.method, uri, None
++ algo, nonce, nc, cnonce, qop, self.originalMethod, uri, None
+ )
+
return expected == response
+@@ -348,7 +364,13 @@
+ auth.get('nonce'),
+ request.remoteAddr.host):
- def checkHash(self, digestHash):
++ if hasattr(request, "originalMethod"):
++ originalMethod = request.originalMethod
++ else:
++ originalMethod = None
++
+ return succeed(DigestedCredentials(username,
+- request.method,
+- self.realm,
+- auth))
++ request.method,
++ self.realm,
++ auth,
++ originalMethod))
Added: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.server.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.server.patch (rev 0)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.server.patch 2009-06-04 00:41:15 UTC (rev 4320)
@@ -0,0 +1,21 @@
+Index: twisted/web2/server.py
+===================================================================
+--- twisted/web2/server.py (revision 26899)
++++ twisted/web2/server.py (working copy)
+@@ -332,6 +332,16 @@
+ response = http.Response(responsecode.OK)
+ response.headers.setHeader('allow', ('GET', 'HEAD', 'OPTIONS', 'TRACE'))
+ return response
++
++ elif self.method == "POST":
++ # Allow other methods to tunnel through using POST and a request header.
++ # See http://code.google.com/apis/gdata/docs/2.0/basics.html
++ if self.headers.hasHeader("X-HTTP-Method-Override"):
++ intendedMethod = self.headers.getRawHeaders("X-HTTP-Method-Override")[0];
++ if intendedMethod:
++ self.originalMethod = self.method
++ self.method = intendedMethod
++
+ # This is where CONNECT would go if we wanted it
+ return None
+
Modified: CalendarServer/trunk/twistedcaldav/directory/digest.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/digest.py 2009-06-04 00:40:36 UTC (rev 4319)
+++ CalendarServer/trunk/twistedcaldav/directory/digest.py 2009-06-04 00:41:15 UTC (rev 4320)
@@ -228,13 +228,20 @@
# Now verify the nonce/cnonce values for this client
result = (yield self._validate(auth, request))
if result:
+ if hasattr(request, "originalMethod"):
+ originalMethod = request.originalMethod
+ else:
+ originalMethod = None
+
credentials = DigestedCredentials(username,
- request.method,
- self.realm,
- auth,
- request.originalMethod if hasattr(request, "originalMethod") else None)
+ request.method,
+ self.realm,
+ auth,
+ originalMethod)
+
if not self.qop and credentials.fields.has_key('qop'):
del credentials.fields['qop']
+
returnValue(credentials)
else:
raise error.LoginFailed('Invalid nonce/cnonce values')
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090603/d80a6289/attachment-0001.html>
More information about the calendarserver-changes
mailing list