def main_loop(self): provider = FabnetProvider(self.nibbler) config = DEFAULT_CONFIG.copy() config.update({ "provider_mapping": {"/": provider}, "user_mapping": {}, "verbose": 1, #"debug_methods": ['OPTIONS', 'PROPFIND', 'GET'], "enable_loggers": [], "propsmanager": True, # True: use property_manager.PropertyManager "locksmanager": True, # True: use lock_manager.LockManager "acceptdigest": False, # Allow digest authentication, True or False "defaultdigest": False, # True (default digest) or False (default basic) "domaincontroller": KSDomainController(self.nibbler.get_security_provider()), "dir_browser": {'response_trailer': "<a href='http://idepositbox.com'>"\ "iDepositBox/%s</a> ${time}"%VERSION} }) app = WsgiDAVApp(config) self.__init_logger() if config["verbose"] >= 1: print("Running %s, listening on %s://%s:%s" % (wsgiserver.CherryPyWSGIServer.version, 'http', self.host, self.port)) self.server = wsgiserver.CherryPyWSGIServer((self.host, self.port), app,) self.server.provider = provider self.server.start()
def _initConfig(self): """Setup configuration dictionary from default, command line and configuration file.""" # Set config defaults config = DEFAULT_CONFIG.copy() temp_verbose = config["verbose"] # Configuration file overrides defaults config_file = os.path.abspath(DEFAULT_CONFIG_FILE) fileConf = self._readConfigFile(config_file, temp_verbose) config.update(fileConf) if not useLxml and config["verbose"] >= 1: print( "WARNING: Could not import lxml: using xml instead (slower). Consider installing lxml from http://codespeak.net/lxml/.") from wsgidav.dir_browser import WsgiDavDirBrowser from wsgidav.debug_filter import WsgiDavDebugFilter from tracim.lib.webdav.tracim_http_authenticator import TracimHTTPAuthenticator from wsgidav.error_printer import ErrorPrinter config['middleware_stack'] = [ WsgiDavDirBrowser, TracimHTTPAuthenticator, ErrorPrinter, WsgiDavDebugFilter ] config['provider_mapping'] = { config['root_path']: Provider( show_archived=config['show_archived'], show_deleted=config['show_deleted'], show_history=config['show_history'], manage_locks=config['manager_locks'] ) } config['domaincontroller'] = TracimDomainController(presetdomain=None, presetserver=None) return config
def _makeWsgiDAVApp(self, withAuthentication): self.rootpath = os.path.join(gettempdir(), "wsgidav-test") if not os.path.exists(self.rootpath): os.mkdir(self.rootpath) provider = FilesystemProvider(self.rootpath) config = DEFAULT_CONFIG.copy() config.update({ "provider_mapping": {"/": provider}, "user_mapping": {}, "verbose": 1, "enable_loggers": [], "propsmanager": None, # None: no property manager "locksmanager": True, # True: use lock_manager.LockManager "domaincontroller": None, # None: domain_controller.WsgiDAVDomainController(user_mapping) }) if withAuthentication: config["user_mapping"] = {"/": {"tester": {"password": "******", "description": "", "roles": [], }, }, } config["acceptbasic"] = True config["acceptdigest"] = False config["defaultdigest"] = False return WsgiDAVApp(config)
def make_server(host, port, fabnet_host): security_provider = SecurityProviderMock() provider = FabnetProvider(fabnet_host, security_provider) config = DEFAULT_CONFIG.copy() config.update({ "provider_mapping": {"/": provider}, "user_mapping": {}, "verbose": 1, "enable_loggers": [], "propsmanager": True, # True: use property_manager.PropertyManager "locksmanager": True, # True: use lock_manager.LockManager "domaincontroller": None, # None: domain_controller.WsgiDAVDomainController(user_mapping) }) app = WsgiDAVApp(config) version = "WsgiDAV/%s %s" % (__version__, wsgiserver.CherryPyWSGIServer.version) wsgiserver.CherryPyWSGIServer.version = version if config["verbose"] >= 1: print("Runing %s, listening on %s://%s:%s" % (version, 'http', host, port)) server = wsgiserver.CherryPyWSGIServer((host, port), app,) server.provider = provider return server
def _initConfig( self, **settings ): """Setup configuration dictionary from default, command line and configuration file.""" # Set config defaults config = DEFAULT_CONFIG.copy() # Get pyramid Env config['tracim_settings'] = settings app_config = CFG(settings) # use only basic_auth, disable digest auth config['acceptbasic'] = True config['acceptdigest'] = False config['defaultdigest'] = False # check this for apache auth mecanism if app_config.REMOTE_USER_HEADER: config['trusted_auth_header'] = app_config.REMOTE_USER_HEADER config['verbose'] = app_config.WEBDAV_VERBOSE_LEVEL config['dir_browser']['enable'] = app_config.WEBDAV_DIR_BROWSER_ENABLED config['dir_browser']['response_trailer'] = app_config.WEBDAV_DIR_BROWSER_FOOTER if not useLxml and config["verbose"] >= 1: print( "WARNING: Could not import lxml: using xml instead (slower). " "consider installing lxml from http://codespeak.net/lxml/." ) config['provider_mapping'] = { app_config.WEBDAV_ROOT_PATH: Provider( show_history=app_config.WEBDAV_SHOW_ARCHIVED, show_archived=app_config.WEBDAV_SHOW_DELETED, show_deleted=app_config.WEBDAV_SHOW_HISTORY, manage_locks=app_config.WEBDAV_MANAGE_LOCK, app_config=app_config, ) } config['block_size'] = app_config.WEBDAV_BLOCK_SIZE config['domaincontroller'] = TracimDomainController( presetdomain=None, presetserver=None, app_config=app_config, ) config['middleware_stack'] = [ TracimEnforceHTTPS, WsgiDavDirBrowser, HTTPAuthenticator, ErrorPrinter, TracimWsgiDavDebugFilter, TracimEnv, ] return config
def run(configuration): """SSL wrapped HTTP server for secure WebDAV access""" dav_conf = configuration.dav_cfg daemon_conf = configuration.daemon_conf config = DEFAULT_CONFIG.copy() config.update(dav_conf) config.update(daemon_conf) user_map = {} update_users(configuration, user_map) config.update({ "provider_mapping": { dav_domain: MiGFilesystemProvider(daemon_conf['root_dir'], configuration, dav_conf) }, "user_mapping": user_map, "enable_loggers": [], "propsmanager": True, # True: use property_manager.PropertyManager "locksmanager": True, # True: use lock_manager.LockManager # Allow last modified timestamp updates from client to support rsync -a "mutable_live_props": ["{DAV:}getlastmodified"], "domaincontroller": MiGWsgiDAVDomainController(user_map), }) #print('User list: %s' % config['user_mapping']) app = WsgiDAVApp(config) # Find and mangle HTTPAuthenticator in application stack #app_authenticator = _find_authenticator(app) #print('Config: %s' % config) #print('app auth: %s' % app_authenticator) if not config.get('nossl', False): cert = config['ssl_certificate'] = configuration.user_davs_key key = config['ssl_private_key'] = configuration.user_davs_key chain = config['ssl_certificate_chain'] = '' #wsgiserver.CherryPyWSGIServer.ssl_adapter = BuiltinSSLAdapter(cert, key, chain) wsgiserver.CherryPyWSGIServer.ssl_adapter = HardenedSSLAdapter(cert, key, chain) # Use bundled CherryPy WSGI Server to support SSL version = "%s WebDAV" % configuration.short_title server = wsgiserver.CherryPyWSGIServer((config["host"], config["port"]), app, server_name=version) logger.info('Listening on %(host)s (%(port)s)' % config) try: server.start() except KeyboardInterrupt: server.stop() # forward KeyboardInterrupt to main thread raise
def dav_for_user(request, login): provider = FilesystemProvider(path.join(settings.DAV_ROOT, login) + "/") config = DEFAULT_CONFIG.copy() config.update({ "provider_mapping": {"/"+login: provider}, "verbose": 1, "enable_loggers": [], "acceptdigest": False, "propsmanager": True, # True: use property_manager.PropertyManager "locksmanager": True, # True: use lock_manager.LockManager "domaincontroller": DjangoDomainController(login), # None: domain_controller.WsgiDAVDomainController(user_mapping) }) return django_view(WsgiDAVApp(config))(request)
def _initConfig(): """Setup configuration dictionary from default, command line and configuration file.""" cmdLineOpts = _initCommandLineOptions() # Set config defaults config = DEFAULT_CONFIG.copy() # Configuration file overrides defaults config_file = cmdLineOpts.get("config_file") if config_file: verbose = cmdLineOpts.get("verbose", 2) fileConf = _readConfigFile(config_file, verbose) config.update(fileConf) else: if cmdLineOpts["verbose"] >= 2: print "Running without configuration file." # Command line overrides file if cmdLineOpts.get("port"): config["port"] = cmdLineOpts.get("port") if cmdLineOpts.get("host"): config["host"] = cmdLineOpts.get("host") if cmdLineOpts.get("verbose") is not None: config["verbose"] = cmdLineOpts.get("verbose") if cmdLineOpts.get("profile") is not None: config["profile"] = True if cmdLineOpts.get("root_path"): root_path = os.path.abspath(cmdLineOpts.get("root_path")) config["provider_mapping"]["/"] = FilesystemProvider(root_path) if cmdLineOpts["verbose"] >= 3: print "Configuration(%s):" % cmdLineOpts["config_file"] pprint(config) if not config["provider_mapping"]: print >>sys.stderr, "ERROR: No DAV provider defined. Try --help option." sys.exit(-1) # raise RuntimeWarning("At least one DAV provider must be specified by a --root option, or in a configuration file.") if cmdLineOpts.get("reload"): print >>sys.stderr, "Installing paste.reloader." from paste import reloader #@UnresolvedImport reloader.install() if config_file: # Add config file changes reloader.watch_file(config_file) # import pydevd # pydevd.settrace() return config
def run_wsgidav_server(with_auth, with_ssl): """Start blocking WsgiDAV server (called as a separate process).""" package_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) share_path = os.path.join(gettempdir(), "wsgidav-test") if not os.path.exists(share_path): os.mkdir(share_path) provider = FilesystemProvider(share_path) config = DEFAULT_CONFIG.copy() config.update({ "host": "127.0.0.1", "port": 8080, "provider_mapping": {"/": provider}, "domaincontroller": None, # None: domain_controller.WsgiDAVDomainController(user_mapping) "user_mapping": {}, "verbose": 0, "enable_loggers": [], "propsmanager": True, # None: no property manager "locksmanager": True, # True: use lock_manager.LockManager "domaincontroller": None, # None: domain_controller.WsgiDAVDomainController(user_mapping) }) if with_auth: config.update({ "user_mapping": {"/": {"tester": {"password": "******", "description": "", "roles": [], }, }, }, "acceptbasic": True, "acceptdigest": False, "defaultdigest": False, }) if with_ssl: config.update({ "ssl_certificate": os.path.join(package_path, "wsgidav/server/sample_bogo_server.crt"), "ssl_private_key": os.path.join(package_path, "wsgidav/server/sample_bogo_server.key"), "ssl_certificate_chain": None, # "acceptdigest": True, # "defaultdigest": True, }) app = WsgiDAVApp(config) from wsgidav.server.run_server import _runBuiltIn _runBuiltIn(app, config, None)
def run(self): withAuthentication = True self.rootpath = os.path.join(gettempdir(), "wsgidav-test") if not os.path.exists(self.rootpath): os.mkdir(self.rootpath) provider = FilesystemProvider(self.rootpath) config = DEFAULT_CONFIG.copy() config.update({ "provider_mapping": {"/": provider}, "user_mapping": {}, "host": "localhost", "port": 8080, "enable_loggers": [ # "http_authenticator", # "lock_manager", ], "debug_methods": [ ], "propsmanager": True, # True: use lock_manager.LockManager "locksmanager": True, # True: use lock_manager.LockManager "domaincontroller": None, # None: domain_controller.WsgiDAVDomainController(user_mapping) "verbose": 2, }) if withAuthentication: config["user_mapping"] = {"/": {"tester": {"password": "******", "description": "", "roles": [], }, "tester2": {"password": "******", "description": "", "roles": [], }, }, } config["acceptbasic"] = True config["acceptdigest"] = False config["defaultdigest"] = False app = WsgiDAVApp(config) self.ext_server = ExtServer((config["host"], config["port"]), {"": app}) self.ext_server.serve_forever_stoppable() self.ext_server = None
def __init__(self,service): root_dav= FilesystemProvider(os.path.join(service.config.location,'dav_store')) config_dav = FilesystemProvider(os.path.join(service.config.location,'dav_store','config')) domain_controller = DjangoDomainController() config = DEFAULT_CONFIG.copy() config.update({ "mount_path": "/dav", "provider_mapping": {"/": root_dav,'/config':config_dav}, "verbose": 1, "enable_loggers": [], "acceptbasic": True, "acceptdigest": False, "defaultdigest": False, "propsmanager": True, # True: use property_manager.PropertyManager "locksmanager": True, # True: use lock_manager.LockManager "domaincontroller": domain_controller, }) self.wsgidav = WsgiDAVApp(config)
def __init__(self): self.__config = DEFAULT_CONFIG.copy() self.__config.update({"host": VDOM_CONFIG["SERVER-ADDRESS"], "port": VDOM_CONFIG["SERVER-DAV-PORT"], "propsmanager": True, "provider_mapping": {}, "acceptbasic": True, # Allow basic authentication, True or False "acceptdigest": True, # Allow digest authentication, True or False "defaultdigest": True, "verbose": 0, "middleware_stack": [ WsgiDavDirBrowser, VDOM_HTTPAuthenticator, ErrorPrinter, WsgiDavDebugFilter, ] }) self.__index = {} app_list = managers.xml_manager.get_applications() for appid in app_list: self.load_webdav(appid)
def _initConfig(): """Setup configuration dictionary from default, command line and configuration file.""" cmdLineOpts, args = _initCommandLineOptions() # Set config defaults config = DEFAULT_CONFIG.copy() if cmdLineOpts["verbose"] is None: temp_verbose = config["verbose"] else: temp_verbose = cmdLineOpts["verbose"] _loadSeafileSettings(config) # Command line options if cmdLineOpts.get("port"): config["port"] = cmdLineOpts.get("port") if cmdLineOpts.get("host"): config["host"] = cmdLineOpts.get("host") if cmdLineOpts.get("verbose") is not None: config["verbose"] = cmdLineOpts.get("verbose") log_path = cmdLineOpts.get("log_path", "") if log_path: log_path = os.path.abspath(log_path) config["log_path"] = log_path pid_file = cmdLineOpts.get("pid_file", "") if pid_file: pid_file = os.path.abspath(pid_file) config["pid_file"] = pid_file if not config["provider_mapping"]: print >>sys.stderr, "ERROR: No DAV provider defined. Try --help option." sys.exit(-1) return config, args
def run_wsgidav_server(with_auth, with_ssl, provider=None, **kwargs): """Start blocking WsgiDAV server (called as a separate process).""" package_path = os.path.abspath( os.path.join(os.path.dirname(__file__), "..")) share_path = os.path.join(gettempdir(), "wsgidav-test") if not os.path.exists(share_path): os.mkdir(share_path) if provider is None: provider = FilesystemProvider(share_path) config = DEFAULT_CONFIG.copy() config.update({ "host": "127.0.0.1", "port": 8080, "provider_mapping": { "/": provider }, # None: domain_controller.WsgiDAVDomainController(user_mapping) "domaincontroller": None, "user_mapping": {}, "verbose": 0, "enable_loggers": [], "propsmanager": True, # None: no property manager "locksmanager": True, # True: use lock_manager.LockManager # None: domain_controller.WsgiDAVDomainController(user_mapping) "domaincontroller": None, }) if with_auth: config.update({ "user_mapping": { "/": { "tester": { "password": "******", "description": "", "roles": [], }, "tester2": { "password": "******", "description": "", "roles": [], }, }, }, "acceptbasic": True, "acceptdigest": False, "defaultdigest": False, }) if with_ssl: config.update({ "ssl_certificate": os.path.join(package_path, "wsgidav/server/sample_bogo_server.crt"), "ssl_private_key": os.path.join(package_path, "wsgidav/server/sample_bogo_server.key"), "ssl_certificate_chain": None, # "acceptdigest": True, # "defaultdigest": True, }) # This event is .set() when server enters the request handler loop if kwargs.get("startup_event"): config["startup_event"] = kwargs["startup_event"] app = WsgiDAVApp(config) # from wsgidav.server.server_cli import _runBuiltIn # _runBuiltIn(app, config, None) from wsgidav.server.server_cli import _runCheroot _runCheroot(app, config, "cheroot")
class ScriptProvider(DAVProvider): def __init__(self, app): super(ScriptProvider, self).__init__() self.app = app def __repr__(self): return "pyspiderScriptProvider" def getResourceInst(self, path, environ): path = os.path.normpath(path) if path in ('/', '.', ''): return RootCollection(path, environ, self.app) else: return ScriptResource(path, environ, self.app) config = DEFAULT_CONFIG.copy() config.update({ 'mount_path': '/dav', 'provider_mapping': { '/': ScriptProvider(app) }, 'user_mapping': {}, 'verbose': 1 if app.debug else 0, 'dir_browser': {'davmount': False, 'enable': True, 'msmount': False, 'response_trailer': ''}, }) dav_app = WsgiDAVApp(config)
def _initConfig(): """Setup configuration dictionary from default, command line and configuration file.""" cmdLineOpts, args = _initCommandLineOptions() # Set config defaults config = DEFAULT_CONFIG.copy() if cmdLineOpts["verbose"] is None: temp_verbose = config["verbose"] else: temp_verbose = cmdLineOpts["verbose"] # print "verbose #1: ", temp_verbose # Configuration file overrides defaults config_file = cmdLineOpts.get("config_file") if config_file: fileConf = _readConfigFile(config_file, temp_verbose) config.update(fileConf) else: if temp_verbose >= 2: print "Running without configuration file." # print "verbose #2: ", config.get("verbose") # Command line overrides file if cmdLineOpts.get("port"): config["port"] = cmdLineOpts.get("port") if cmdLineOpts.get("host"): config["host"] = cmdLineOpts.get("host") if cmdLineOpts.get("verbose") is not None: config["verbose"] = cmdLineOpts.get("verbose") if cmdLineOpts.get("profile") is not None: config["profile"] = True if cmdLineOpts.get("root_path"): root_path = os.path.abspath(cmdLineOpts.get("root_path")) config["provider_mapping"]["/"] = FilesystemProvider(root_path) if config["verbose"] >= 3: print "Configuration(%s):" % cmdLineOpts["config_file"] pprint(config) log_path = cmdLineOpts.get("log_path", "") if log_path: log_path = os.path.abspath(log_path) config["log_path"] = log_path pid_file = cmdLineOpts.get("pid_file", "") if pid_file: pid_file = os.path.abspath(pid_file) config["pid_file"] = pid_file if not useLxml and config["verbose"] >= 1: print "WARNING: Could not import lxml: using xml instead (slower). Consider installing lxml from http://codespeak.net/lxml/." # print "verbose #3: ", config.get("verbose") if not config["provider_mapping"]: print >>sys.stderr, "ERROR: No DAV provider defined. Try --help option." sys.exit(-1) # raise RuntimeWarning("At least one DAV provider must be specified by a --root option, or in a configuration file.") if cmdLineOpts.get("reload"): print >>sys.stderr, "Installing paste.reloader." from paste import reloader #@UnresolvedImport reloader.install() if config_file: # Add config file changes reloader.watch_file(config_file) # import pydevd # pydevd.settrace() return config, args
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php """ Simple example how to a run WsgiDAV in a 3rd-party WSGI server. """ from tempfile import gettempdir from wsgidav.fs_dav_provider import FilesystemProvider from wsgidav.version import __version__ from wsgidav.wsgidav_app import DEFAULT_CONFIG, WsgiDAVApp __docformat__ = "reStructuredText" rootpath = gettempdir() provider = FilesystemProvider(rootpath) config = DEFAULT_CONFIG.copy() config.update({ "provider_mapping": {"/": provider}, "user_mapping": {}, "verbose": 1, "enable_loggers": [], "propsmanager": True, # True: use property_manager.PropertyManager "locksmanager": True, # True: use lock_manager.LockManager "domaincontroller": None, # None: domain_controller.WsgiDAVDomainController(user_mapping) }) app = WsgiDAVApp(config) # For an example. use paste.httpserver # (See http://pythonpaste.org/modules/httpserver.html for more options) from paste import httpserver httpserver.serve(app,
def _initConfig(): """Setup configuration dictionary from default, command line and configuration file.""" cmdLineOpts = _initCommandLineOptions() # Set config defaults config = DEFAULT_CONFIG.copy() if cmdLineOpts["verbose"] is None: temp_verbose = config["verbose"] else: temp_verbose = cmdLineOpts["verbose"] # print "verbose #1: ", temp_verbose # Configuration file overrides defaults config_file = cmdLineOpts.get("config_file") if config_file: fileConf = _readConfigFile(config_file, temp_verbose) config.update(fileConf) else: if temp_verbose >= 2: print("Running without configuration file.") # print "verbose #2: ", config.get("verbose") # Command line overrides file if cmdLineOpts.get("port"): config["port"] = cmdLineOpts.get("port") if cmdLineOpts.get("host"): config["host"] = cmdLineOpts.get("host") if cmdLineOpts.get("verbose") is not None: config["verbose"] = cmdLineOpts.get("verbose") if cmdLineOpts.get("profile") is not None: config["profile"] = True if cmdLineOpts.get("server") is not None: config["server"] = cmdLineOpts.get("server") if cmdLineOpts.get("ssl_adapter") is not None: config["ssl_adapter"] = cmdLineOpts.get("ssl_adapter") if cmdLineOpts.get("root_path"): root_path = os.path.abspath(cmdLineOpts.get("root_path")) config["provider_mapping"]["/"] = FilesystemProvider(root_path) if config["verbose"] >= 3: print("Configuration(%s):" % cmdLineOpts["config_file"]) pprint(config) # if not useLxml and config["verbose"] >= 1: # print("WARNING: Could not import lxml: using xml instead (slower). Consider installing" # "lxml from http://codespeak.net/lxml/.") # print "verbose #3: ", config.get("verbose") if not config["provider_mapping"]: print("ERROR: No DAV provider defined. Try --help option.", file=sys.stderr) sys.exit(-1) # raise RuntimeWarning("At least one DAV provider must be specified by a --root option," # or in a configuration file.") if cmdLineOpts.get("reload"): print("Installing paste.reloader.", file=sys.stderr) from paste import reloader # @UnresolvedImport reloader.install() if config_file: # Add config file changes reloader.watch_file(config_file) # import pydevd # pydevd.settrace() return config