[CalendarServer-changes] [13833] CalendarServer/trunk/txdav
source_changes at macosforge.org
source_changes at macosforge.org
Mon Aug 4 14:50:02 PDT 2014
Revision: 13833
http://trac.calendarserver.org//changeset/13833
Author: sagen at apple.com
Date: 2014-08-04 14:50:02 -0700 (Mon, 04 Aug 2014)
Log Message:
-----------
Auth caching
Modified Paths:
--------------
CalendarServer/trunk/txdav/dps/server.py
CalendarServer/trunk/txdav/who/cache.py
CalendarServer/trunk/txdav/who/directory.py
Modified: CalendarServer/trunk/txdav/dps/server.py
===================================================================
--- CalendarServer/trunk/txdav/dps/server.py 2014-08-04 20:41:18 UTC (rev 13832)
+++ CalendarServer/trunk/txdav/dps/server.py 2014-08-04 21:50:02 UTC (rev 13833)
@@ -387,7 +387,17 @@
record = (yield self._directory.recordWithUID(uid))
authenticated = False
if record is not None:
+ try:
+ if record._cached_password == password:
+ response = {
+ "authenticated": True,
+ }
+ returnValue(response)
+ except AttributeError:
+ pass
authenticated = (yield record.verifyPlaintextPassword(password))
+ if authenticated:
+ record._cached_password = password
response = {
"authenticated": authenticated,
}
Modified: CalendarServer/trunk/txdav/who/cache.py
===================================================================
--- CalendarServer/trunk/txdav/who/cache.py 2014-08-04 20:41:18 UTC (rev 13832)
+++ CalendarServer/trunk/txdav/who/cache.py 2014-08-04 21:50:02 UTC (rev 13833)
@@ -72,15 +72,12 @@
directory records.
"""
- # FIXME: purge old records occasionally
-
fieldName = ConstantsContainer((
BaseFieldName,
FieldName,
))
-
def __init__(self, directory, expireSeconds=30):
BaseDirectoryService.__init__(self, directory.realmName)
self._directory = directory
Modified: CalendarServer/trunk/txdav/who/directory.py
===================================================================
--- CalendarServer/trunk/txdav/who/directory.py 2014-08-04 20:41:18 UTC (rev 13832)
+++ CalendarServer/trunk/txdav/who/directory.py 2014-08-04 21:50:02 UTC (rev 13833)
@@ -269,9 +269,15 @@
if isinstance(credentials, UsernamePassword):
log.debug("UsernamePassword")
- returnValue(
- (yield self.verifyPlaintextPassword(credentials.password))
- )
+ try:
+ if self._cached_password == credentials.password:
+ returnValue(True)
+ except AttributeError:
+ pass
+ matches = yield self.verifyPlaintextPassword(credentials.password)
+ if matches:
+ self._cached_password = credentials.password
+ returnValue(matches)
elif isinstance(credentials, DigestedCredentials):
log.debug("DigestedCredentials")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140804/9328faf1/attachment-0001.html>
More information about the calendarserver-changes
mailing list