[CalendarServer-changes] [12422] CalendarServer/branches/newdirectory
source_changes at macosforge.org
source_changes at macosforge.org
Wed Mar 12 11:18:53 PDT 2014
Revision: 12422
http://trac.calendarserver.org//changeset/12422
Author: wsanchez at apple.com
Date: 2014-01-22 12:29:15 -0800 (Wed, 22 Jan 2014)
Log Message:
-----------
FIrst pass
Modified Paths:
--------------
CalendarServer/branches/newdirectory/calendarserver/tap/util.py
CalendarServer/branches/newdirectory/twistedcaldav/directory/directory.py
CalendarServer/branches/newdirectory/twistedcaldav/stdconfig.py
Modified: CalendarServer/branches/newdirectory/calendarserver/tap/util.py
===================================================================
--- CalendarServer/branches/newdirectory/calendarserver/tap/util.py 2014-01-22 19:11:53 UTC (rev 12421)
+++ CalendarServer/branches/newdirectory/calendarserver/tap/util.py 2014-01-22 20:29:15 UTC (rev 12422)
@@ -28,79 +28,87 @@
import errno
import os
-from time import sleep
+# from time import sleep
from socket import fromfd, AF_UNIX, SOCK_STREAM, socketpair
import psutil
+from urllib import quote
from twext.python.filepath import CachingFilePath as FilePath
from twext.python.log import Logger
-from txweb2.auth.basic import BasicCredentialFactory
-from txweb2.dav import auth
-from txweb2.http_headers import Headers
-from txweb2.resource import Resource
-from txweb2.static import File as FileResource
+from twisted.python.usage import UsageError
+from twext.enterprise.ienterprise import POSTGRES_DIALECT
+from twext.enterprise.ienterprise import ORACLE_DIALECT
+from twext.enterprise.adbapi2 import (
+ ConnectionPool, ConnectionPoolConnection, ConnectionPoolClient
+)
+from twext.who.aggregate import AggregateDirectoryService
from twisted.application.service import Service
from twisted.cred.portal import Portal
-from twisted.internet.defer import inlineCallbacks, returnValue, Deferred, succeed
+from twisted.internet.defer import (
+ inlineCallbacks, returnValue, Deferred, succeed
+)
from twisted.internet import reactor as _reactor
from twisted.internet.reactor import addSystemEventTrigger
from twisted.internet.tcp import Connection
from twisted.python.reflect import namedClass
# from twisted.python.failure import Failure
+from txweb2.auth.basic import BasicCredentialFactory
+from txweb2.dav import auth
+from txweb2.http_headers import Headers
+from txweb2.resource import Resource
+from txweb2.static import File as FileResource
+
+from txdav.base.datastore.dbapiclient import DBAPIConnector, OracleConnector
+from txdav.base.datastore.dbapiclient import postgresPreflight
+from txdav.base.datastore.subpostgres import PostgresService
+from txdav.common.datastore.podding.resource import ConduitResource
+from txdav.common.datastore.sql import CommonDataStore as CommonSQLDataStore
+from txdav.common.datastore.file import CommonDataStore as CommonFileDataStore
+from txdav.common.datastore.sql import current_sql_schema
+from txdav.common.datastore.upgrade.sql.upgrade import NotAllowedToUpgrade
+from txdav.caldav.datastore.scheduling.ischedule.dkim import (
+ DKIMUtils, DomainKeyResource
+)
+from txdav.caldav.datastore.scheduling.ischedule.resource import (
+ IScheduleInboxResource
+)
+
+from twistedcaldav.config import ConfigurationError
from twistedcaldav.bind import doBind
from twistedcaldav.cache import CacheStoreNotifierFactory
from twistedcaldav.directory import calendaruserproxy
from twistedcaldav.directory.addressbook import DirectoryAddressBookHomeProvisioningResource
-from twistedcaldav.directory.aggregate import AggregateDirectoryService
+# from twistedcaldav.directory.aggregate import AggregateDirectoryService
from twistedcaldav.directory.calendar import DirectoryCalendarHomeProvisioningResource
from twistedcaldav.directory.digest import QopDigestCredentialFactory
-from twistedcaldav.directory.directory import GroupMembershipCache
+# from twistedcaldav.directory.directory import GroupMembershipCache
from twistedcaldav.directory.principal import DirectoryPrincipalProvisioningResource
-from twistedcaldav.directory.wiki import WikiDirectoryService
-from calendarserver.push.notifier import NotifierFactory
-from calendarserver.push.applepush import APNSubscriptionResource
-from twistedcaldav.directorybackedaddressbook import DirectoryBackedAddressBookResource
+# from twistedcaldav.directory.wiki import WikiDirectoryService
+from twistedcaldav.directorybackedaddressbook import (
+ DirectoryBackedAddressBookResource
+)
from twistedcaldav.resource import AuthenticationWrapper
-from txdav.caldav.datastore.scheduling.ischedule.dkim import DKIMUtils, DomainKeyResource
-from txdav.caldav.datastore.scheduling.ischedule.resource import IScheduleInboxResource
from twistedcaldav.simpleresource import SimpleResource, SimpleRedirectResource
from twistedcaldav.timezones import TimezoneCache
from twistedcaldav.timezoneservice import TimezoneServiceResource
from twistedcaldav.timezonestdservice import TimezoneStdServiceResource
-from twext.enterprise.ienterprise import POSTGRES_DIALECT
-from twext.enterprise.ienterprise import ORACLE_DIALECT
-from twext.enterprise.adbapi2 import ConnectionPool, ConnectionPoolConnection
-
try:
from twistedcaldav.authkerb import NegotiateCredentialFactory
- NegotiateCredentialFactory # pacify pyflakes
except ImportError:
NegotiateCredentialFactory = None
-from twext.enterprise.adbapi2 import ConnectionPoolClient
-from txdav.base.datastore.dbapiclient import DBAPIConnector, OracleConnector
-from txdav.base.datastore.dbapiclient import postgresPreflight
-from txdav.base.datastore.subpostgres import PostgresService
-
+from calendarserver.push.notifier import NotifierFactory
+from calendarserver.push.applepush import APNSubscriptionResource
from calendarserver.accesslog import DirectoryLogWrapperResource
from calendarserver.provision.root import RootResource
from calendarserver.tools.util import checkDirectory
from calendarserver.webadmin.resource import WebAdminResource
from calendarserver.webcal.resource import WebCalendarResource
-from txdav.common.datastore.podding.resource import ConduitResource
-from txdav.common.datastore.sql import CommonDataStore as CommonSQLDataStore
-from txdav.common.datastore.file import CommonDataStore as CommonFileDataStore
-from txdav.common.datastore.sql import current_sql_schema
-from txdav.common.datastore.upgrade.sql.upgrade import NotAllowedToUpgrade
-from twext.python.filepath import CachingFilePath
-from urllib import quote
-from twisted.python.usage import UsageError
-
log = Logger()
@@ -122,7 +130,7 @@
@rtype: L{PostgresService}
"""
- dbRoot = CachingFilePath(config.DatabaseRoot)
+ dbRoot = FilePath(config.DatabaseRoot)
# Construct a PostgresService exactly as the parent would, so that we
# can establish connection information.
return PostgresService(
@@ -237,7 +245,7 @@
notifierFactories["cache"] = CacheStoreNotifierFactory()
if directoryService is None:
- directoryService = directoryFromConfig(config)
+ directoryService = directoryServiceFromConfig(config)
quota = config.UserQuota
if quota == 0:
@@ -281,93 +289,109 @@
-def directoryFromConfig(config):
+def directoryServiceFromSubConfig(subConfig):
+ name = subConfig["name"]
+
+ log.info("Setting up {0} directory service.".format(name))
+
+ if name == "XML":
+ directoryClass = namedClass("twext.who.xml.DirectoryService")
+ filePath = FilePath(subConfig["path"])
+ reloadInterval = int(
+ subConfig.get("reloadInterval", directoryClass.reloadInterval)
+ )
+ directory = directoryClass(filePath)
+ directory.reloadInterval = reloadInterval
+
+ else:
+ raise ConfigurationError(
+ "Unknown directory service name: {0}".format(name)
+ )
+
+
+
+def directoryServiceFromConfig(config):
"""
Create an L{AggregateDirectoryService} from the given configuration.
"""
- #
- # Setup the Augment Service
- #
- if config.AugmentService.type:
- augmentClass = namedClass(config.AugmentService.type)
- log.info("Configuring augment service of type: {augmentClass}",
- augmentClass=augmentClass)
- try:
- augmentService = augmentClass(**config.AugmentService.params)
- except IOError:
- log.error("Could not start augment service")
- raise
- else:
- augmentService = None
+ # #
+ # # Setup the Augment Service
+ # #
+ # if config.AugmentService.type:
+ # augmentClass = namedClass(config.AugmentService.type)
+ # log.info("Configuring augment service of type: {augmentClass}",
+ # augmentClass=augmentClass)
+ # try:
+ # augmentService = augmentClass(**config.AugmentService.params)
+ # except IOError:
+ # log.error("Could not start augment service")
+ # raise
+ # else:
+ # augmentService = None
- #
- # Setup the group membership cacher
- #
- if config.GroupCaching.Enabled:
- groupMembershipCache = GroupMembershipCache(
- config.GroupCaching.MemcachedPool,
- expireSeconds=config.GroupCaching.ExpireSeconds)
- else:
- groupMembershipCache = None
+ # #
+ # # Setup the group membership cacher
+ # #
+ # if config.GroupCaching.Enabled:
+ # groupMembershipCache = GroupMembershipCache(
+ # config.GroupCaching.MemcachedPool,
+ # expireSeconds=config.GroupCaching.ExpireSeconds)
+ # else:
+ # groupMembershipCache = None
+ # config.DirectoryService.params.augmentService = augmentService
+ # config.DirectoryService.params.groupMembershipCache = groupMembershipCache
+
#
# Setup the Directory
#
- directories = []
+ services = []
- directoryClass = namedClass(config.DirectoryService.type)
- principalResourceClass = DirectoryPrincipalProvisioningResource
+ baseService = directoryServiceFromSubConfig(config.DirectoryService)
+ services.append(baseService)
- log.info("Configuring directory service of type: {directoryType}",
- directoryType=config.DirectoryService.type)
+ # # Wait for the directory to become available
+ # while not baseService.isAvailable():
+ # sleep(5)
- config.DirectoryService.params.augmentService = augmentService
- config.DirectoryService.params.groupMembershipCache = groupMembershipCache
- baseDirectory = directoryClass(config.DirectoryService.params)
+ # #
+ # # Setup the Locations and Resources Service
+ # #
+ # if config.ResourceService.Enabled:
+ # resourceClass = namedClass(config.ResourceService.type)
- # Wait for the directory to become available
- while not baseDirectory.isAvailable():
- sleep(5)
+ # log.info("Configuring resource service of type: {resourceClass}",
+ # resourceClass=resourceClass)
- directories.append(baseDirectory)
+ # # config.ResourceService.params.augmentService = augmentService
+ # # config.ResourceService.params.groupMembershipCache = groupMembershipCache
+ # resourceDirectory = resourceClass(config.ResourceService.params)
+ # resourceDirectory.realmName = baseDirectory.realmName
+ # directories.append(resourceDirectory)
- #
- # Setup the Locations and Resources Service
- #
- if config.ResourceService.Enabled:
- resourceClass = namedClass(config.ResourceService.type)
+ # #
+ # # Add wiki directory service
+ # #
+ # if config.Authentication.Wiki.Enabled:
+ # wikiDirectory = WikiDirectoryService()
+ # wikiDirectory.realmName = baseDirectory.realmName
+ # directories.append(wikiDirectory)
- log.info("Configuring resource service of type: {resourceClass}",
- resourceClass=resourceClass)
-
- config.ResourceService.params.augmentService = augmentService
- config.ResourceService.params.groupMembershipCache = groupMembershipCache
- resourceDirectory = resourceClass(config.ResourceService.params)
- resourceDirectory.realmName = baseDirectory.realmName
- directories.append(resourceDirectory)
-
#
- # Add wiki directory service
+ # Use system-wide realm on OSX
#
- if config.Authentication.Wiki.Enabled:
- wikiDirectory = WikiDirectoryService()
- wikiDirectory.realmName = baseDirectory.realmName
- directories.append(wikiDirectory)
+ # try:
+ # import ServerFoundation
+ # realmName = ServerFoundation.XSAuthenticator.defaultRealm().encode("utf-8")
+ # except ImportError:
+ # pass
- directory = AggregateDirectoryService(directories, groupMembershipCache)
+ aggregateService = AggregateDirectoryService(
+ baseService.realmName, services
+ )
+ DirectoryPrincipalProvisioningResource("/principals/", aggregateService)
- #
- # Use system-wide realm on OSX
- #
- try:
- import ServerFoundation
- realmName = ServerFoundation.XSAuthenticator.defaultRealm().encode("utf-8")
- directory.setRealm(realmName)
- except ImportError:
- pass
- log.info("Setting up principal collection: {cls}", cls=principalResourceClass)
- principalResourceClass("/principals/", directory)
- return directory
+ return aggregateService
Modified: CalendarServer/branches/newdirectory/twistedcaldav/directory/directory.py
===================================================================
--- CalendarServer/branches/newdirectory/twistedcaldav/directory/directory.py 2014-01-22 19:11:53 UTC (rev 12421)
+++ CalendarServer/branches/newdirectory/twistedcaldav/directory/directory.py 2014-01-22 20:29:15 UTC (rev 12422)
@@ -15,6 +15,7 @@
# limitations under the License.
##
+raise NotImplementedError("!!!!! die !!!!!")
"""
Generic directory service classes.
Modified: CalendarServer/branches/newdirectory/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/branches/newdirectory/twistedcaldav/stdconfig.py 2014-01-22 19:11:53 UTC (rev 12421)
+++ CalendarServer/branches/newdirectory/twistedcaldav/stdconfig.py 2014-01-22 20:29:15 UTC (rev 12422)
@@ -48,120 +48,120 @@
else:
DEFAULT_CONFIG_FILE = "/etc/caldavd/caldavd.plist"
-DEFAULT_SERVICE_PARAMS = {
- "twistedcaldav.directory.xmlfile.XMLDirectoryService": {
+DEFAULT_SERVICE_CONFIG = {
+ "XML": {
"xmlFile": "accounts.xml",
"recordTypes": ("users", "groups"),
- "statSeconds" : 15,
+ "statSeconds": 15,
},
- "twistedcaldav.directory.appleopendirectory.OpenDirectoryService": {
- "node": "/Search",
- "cacheTimeout": 1, # Minutes
- "batchSize": 100, # for splitting up large queries
- "negativeCaching": False,
- "restrictEnabledRecords": False,
- "restrictToGroup": "",
- "recordTypes": ("users", "groups"),
- },
- "twistedcaldav.directory.ldapdirectory.LdapDirectoryService": {
- "cacheTimeout": 1, # Minutes
- "negativeCaching": False,
- "warningThresholdSeconds": 3,
- "batchSize": 500, # for splitting up large queries
- "requestTimeoutSeconds" : 10,
- "requestResultsLimit" : 200,
- "optimizeMultiName" : False,
- "queryLocationsImplicitly": True,
- "restrictEnabledRecords": False,
- "restrictToGroup": "",
- "recordTypes": ("users", "groups"),
- "uri": "ldap://localhost/",
- "tls": False,
- "tlsCACertFile": None,
- "tlsCACertDir": None,
- "tlsRequireCert": None, # never, allow, try, demand, hard
- "credentials": {
- "dn": None,
- "password": None,
- },
- "authMethod": "LDAP",
- "rdnSchema": {
- "base": "dc=example,dc=com",
- "guidAttr": "entryUUID",
- "users": {
- "rdn": "ou=People",
- "attr": "uid", # used only to synthesize email address
- "emailSuffix": None, # used only to synthesize email address
- "filter": None, # additional filter for this type
- "loginEnabledAttr" : "", # attribute controlling login
- "loginEnabledValue" : "yes", # "True" value of above attribute
- "calendarEnabledAttr" : "", # attribute controlling enabledForCalendaring
- "calendarEnabledValue" : "yes", # "True" value of above attribute
- "mapping" : { # maps internal record names to LDAP
- "recordName": "uid",
- "fullName" : "cn",
- "emailAddresses" : ["mail"],
- "firstName" : "givenName",
- "lastName" : "sn",
- },
- },
- "groups": {
- "rdn": "ou=Group",
- "attr": "cn", # used only to synthesize email address
- "emailSuffix": None, # used only to synthesize email address
- "filter": None, # additional filter for this type
- "mapping" : { # maps internal record names to LDAP
- "recordName": "cn",
- "fullName" : "cn",
- "emailAddresses" : ["mail"],
- "firstName" : "givenName",
- "lastName" : "sn",
- },
- },
- "locations": {
- "rdn": "ou=Places",
- "attr": "cn", # used only to synthesize email address
- "emailSuffix": None, # used only to synthesize email address
- "filter": None, # additional filter for this type
- "calendarEnabledAttr" : "", # attribute controlling enabledForCalendaring
- "calendarEnabledValue" : "yes", # "True" value of above attribute
- "mapping" : { # maps internal record names to LDAP
- "recordName": "cn",
- "fullName" : "cn",
- "emailAddresses" : ["mail"],
- "firstName" : "givenName",
- "lastName" : "sn",
- },
- },
- "resources": {
- "rdn": "ou=Resources",
- "attr": "cn", # used only to synthesize email address
- "emailSuffix": None, # used only to synthesize email address
- "filter": None, # additional filter for this type
- "calendarEnabledAttr" : "", # attribute controlling enabledForCalendaring
- "calendarEnabledValue" : "yes", # "True" value of above attribute
- "mapping" : { # maps internal record names to LDAP
- "recordName": "cn",
- "fullName" : "cn",
- "emailAddresses" : ["mail"],
- "firstName" : "givenName",
- "lastName" : "sn",
- },
- },
- },
- "groupSchema": {
- "membersAttr": "member", # how members are specified
- "nestedGroupsAttr": None, # how nested groups are specified
- "memberIdAttr": None, # which attribute the above refer to
- },
- "resourceSchema": {
- "resourceInfoAttr": None, # contains location/resource info
- "autoAcceptGroupAttr": None, # auto accept group
- },
- "poddingSchema": {
- "serverIdAttr": None, # maps to augments server-id
- },
- },
+ # "twistedcaldav.directory.appleopendirectory.OpenDirectoryService": {
+ # "node": "/Search",
+ # "cacheTimeout": 1, # Minutes
+ # "batchSize": 100, # for splitting up large queries
+ # "negativeCaching": False,
+ # "restrictEnabledRecords": False,
+ # "restrictToGroup": "",
+ # "recordTypes": ("users", "groups"),
+ # },
+ # "twistedcaldav.directory.ldapdirectory.LdapDirectoryService": {
+ # "cacheTimeout": 1, # Minutes
+ # "negativeCaching": False,
+ # "warningThresholdSeconds": 3,
+ # "batchSize": 500, # for splitting up large queries
+ # "requestTimeoutSeconds" : 10,
+ # "requestResultsLimit" : 200,
+ # "optimizeMultiName" : False,
+ # "queryLocationsImplicitly": True,
+ # "restrictEnabledRecords": False,
+ # "restrictToGroup": "",
+ # "recordTypes": ("users", "groups"),
+ # "uri": "ldap://localhost/",
+ # "tls": False,
+ # "tlsCACertFile": None,
+ # "tlsCACertDir": None,
+ # "tlsRequireCert": None, # never, allow, try, demand, hard
+ # "credentials": {
+ # "dn": None,
+ # "password": None,
+ # },
+ # "authMethod": "LDAP",
+ # "rdnSchema": {
+ # "base": "dc=example,dc=com",
+ # "guidAttr": "entryUUID",
+ # "users": {
+ # "rdn": "ou=People",
+ # "attr": "uid", # used only to synthesize email address
+ # "emailSuffix": None, # used only to synthesize email address
+ # "filter": None, # additional filter for this type
+ # "loginEnabledAttr" : "", # attribute controlling login
+ # "loginEnabledValue" : "yes", # "True" value of above attribute
+ # "calendarEnabledAttr" : "", # attribute controlling enabledForCalendaring
+ # "calendarEnabledValue" : "yes", # "True" value of above attribute
+ # "mapping" : { # maps internal record names to LDAP
+ # "recordName": "uid",
+ # "fullName" : "cn",
+ # "emailAddresses" : ["mail"],
+ # "firstName" : "givenName",
+ # "lastName" : "sn",
+ # },
+ # },
+ # "groups": {
+ # "rdn": "ou=Group",
+ # "attr": "cn", # used only to synthesize email address
+ # "emailSuffix": None, # used only to synthesize email address
+ # "filter": None, # additional filter for this type
+ # "mapping" : { # maps internal record names to LDAP
+ # "recordName": "cn",
+ # "fullName" : "cn",
+ # "emailAddresses" : ["mail"],
+ # "firstName" : "givenName",
+ # "lastName" : "sn",
+ # },
+ # },
+ # "locations": {
+ # "rdn": "ou=Places",
+ # "attr": "cn", # used only to synthesize email address
+ # "emailSuffix": None, # used only to synthesize email address
+ # "filter": None, # additional filter for this type
+ # "calendarEnabledAttr" : "", # attribute controlling enabledForCalendaring
+ # "calendarEnabledValue" : "yes", # "True" value of above attribute
+ # "mapping" : { # maps internal record names to LDAP
+ # "recordName": "cn",
+ # "fullName" : "cn",
+ # "emailAddresses" : ["mail"],
+ # "firstName" : "givenName",
+ # "lastName" : "sn",
+ # },
+ # },
+ # "resources": {
+ # "rdn": "ou=Resources",
+ # "attr": "cn", # used only to synthesize email address
+ # "emailSuffix": None, # used only to synthesize email address
+ # "filter": None, # additional filter for this type
+ # "calendarEnabledAttr" : "", # attribute controlling enabledForCalendaring
+ # "calendarEnabledValue" : "yes", # "True" value of above attribute
+ # "mapping" : { # maps internal record names to LDAP
+ # "recordName": "cn",
+ # "fullName" : "cn",
+ # "emailAddresses" : ["mail"],
+ # "firstName" : "givenName",
+ # "lastName" : "sn",
+ # },
+ # },
+ # },
+ # "groupSchema": {
+ # "membersAttr": "member", # how members are specified
+ # "nestedGroupsAttr": None, # how nested groups are specified
+ # "memberIdAttr": None, # which attribute the above refer to
+ # },
+ # "resourceSchema": {
+ # "resourceInfoAttr": None, # contains location/resource info
+ # "autoAcceptGroupAttr": None, # auto accept group
+ # },
+ # "poddingSchema": {
+ # "serverIdAttr": None, # maps to augments server-id
+ # },
+ # },
}
DEFAULT_RESOURCE_PARAMS = {
@@ -372,8 +372,8 @@
# users, groups, locations and resources) to the server.
#
"DirectoryService": {
- "type": "twistedcaldav.directory.xmlfile.XMLDirectoryService",
- "params": DEFAULT_SERVICE_PARAMS["twistedcaldav.directory.xmlfile.XMLDirectoryService"],
+ "name": "XML",
+ "config": DEFAULT_SERVICE_CONFIG["XML"],
},
#
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/2ceeadec/attachment.html>
More information about the calendarserver-changes
mailing list