def startDAVServer(rootPath, directoryInitializer, authorizer, pathMapper): if not os.path.exists(rootPath): os.makedirs(rootPath) provider = WTFilesystemProvider(rootPath, pathMapper) realm = pathMapper.getRealm() config = DEFAULT_CONFIG.copy() # Accept basic authentication and assume access through HTTPS only. This (HTTPS when only # basic is accepted) is enforced by some clients. # The reason for not accepting digest authentication is that it would require storage of # unsalted password hashes on the server. Maybe that's OK, since one could store # HA1 (md5(username:realm:password)) as specified by the digest auth RFC, which would make # it harder to use pre-computed hashes. But for now, this seems simpler. config.update({ 'mount_path': '/' + realm, 'wt_home_dirs_root': rootPath, 'provider_mapping': {'/': provider}, 'user_mapping': {}, 'middleware_stack': [WsgiDavDirBrowser, directoryInitializer, authorizer, HTTPAuthenticator, ErrorPrinter, WsgiDavDebugFilter], 'acceptbasic': True, 'acceptdigest': False, 'defaultdigest': False, 'domaincontroller': WTDomainController(realm), 'server': 'cherrypy' }) # Increase verbosity when running tests. if 'GIRDER_TEST_ASSETSTORE' in os.environ: config.update({'verbose': 2}) global HOME_DIRS_APPS app = WTDAVApp(config) HOME_DIRS_APPS.add(realm, pathMapper, app) cherrypy.tree.graft(app, '/' + realm)
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 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 _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 start_server(): launch_file_monitor() provider = FilesystemProvider('workspace') config = DEFAULT_CONFIG.copy() config.update({ "mount_path": "/dav", "provider_mapping": { "/": provider }, "user_mapping": {}, "verbose": 1, }) dav_app = WsgiDAVApp(config) cors_dav_app = CORS(dav_app, headers="*", methods="*", maxage="180", origin="*") # CORS middleware doesn't like exc_info filtered_dav_app = DAVFilterMiddleWare(cors_dav_app) filtered_dav_app = GzipMiddleware(filtered_dav_app, mime_types=[ 'application/javascript', 'application/x-rapyd', 'application/xml', 'image/svg+xml', 'text/*' ]) app.wsgi_app = DispatcherMiddleware(app.wsgi_app, {'/dav': filtered_dav_app}) socketio.run(app, host='0.0.0.0', port=54991)
def main(): 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 CherryPy from cherrypy.wsgiserver import CherryPyWSGIServer server = CherryPyWSGIServer( bind_addr=(config["host"], config["port"]), wsgi_app=app, server_name="WsgiDAV/%s %s" % (__version__, CherryPyWSGIServer.version), ) try: server.start() except KeyboardInterrupt: print("Caught Ctrl-C, shutting down...") finally: server.stop()
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 test_unit__initConfig__ok__nominal_case(self): """ Check if config is correctly modify for wsgidav using mocked wsgidav and tracim conf (as dict) :return: """ tracim_settings = self.settings wsgidav_setting = DEFAULT_CONFIG.copy() wsgidav_setting.update( { 'root_path': '', 'acceptbasic': True, 'acceptdigest': False, 'defaultdigest': False, } ) mock = MagicMock() mock._initConfig = WebdavAppFactory._initConfig mock._readConfigFile.return_value = wsgidav_setting mock._get_tracim_settings.return_value = tracim_settings config = mock._initConfig(mock) assert config assert config['acceptbasic'] is True assert config['acceptdigest'] is False assert config['defaultdigest'] is False # TODO - G.M - 25-05-2018 - Better check for middleware stack config assert 'middleware_stack' in config assert len(config['middleware_stack']) == 7 assert 'root_path' in config assert 'provider_mapping' in config assert config['root_path'] in config['provider_mapping'] assert isinstance(config['provider_mapping'][config['root_path']], Provider) # nopep8 assert 'domaincontroller' in config assert isinstance(config['domaincontroller'], TracimDomainController)
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 _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(self): print("WsgiDAVServerThread.run()...") 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": SERVER_HOST, "port": SERVER_PORT, "enable_loggers": [ # "http_authenticator", # "lock_manager", ], "debug_methods": [], "propsmanager": True, # True: use lock_manager.LockManager "locksmanager": True, # True: use lock_manager.LockManager # None: domain_controller.WsgiDAVDomainController(user_mapping) "domaincontroller": None, "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}) print("WsgiDAVServerThread ext_server.serve_forever_stoppable()...") self.ext_server.serve_forever_stoppable() print("WsgiDAVServerThread ext_server stopped.") self.ext_server = None
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 _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 _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 _initConfig(self, tracim_config_file_path: str = None): """Setup configuration dictionary from default, command line and configuration file.""" if not tracim_config_file_path: tracim_config_file_path = DEFAULT_TRACIM_CONFIG_FILE # Set config defaults config = DEFAULT_CONFIG.copy() temp_verbose = config["verbose"] # Get pyramid Env tracim_config_file_path = os.path.abspath(tracim_config_file_path) config['tracim_config'] = tracim_config_file_path settings = self._get_tracim_settings(config) app_config = CFG(settings) default_config_file = os.path.abspath(settings['wsgidav.config_path']) webdav_config_file = self._readConfigFile(default_config_file, temp_verbose) # Configuration file overrides defaults config.update(webdav_config_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/.") config['middleware_stack'] = [ TracimEnforceHTTPS, WsgiDavDirBrowser, TracimUserSession, HTTPAuthenticator, ErrorPrinter, TracimWsgiDavDebugFilter, TracimEnv, ] config['provider_mapping'] = { config['root_path']: Provider( # TODO: Test to Re enabme archived and deleted show_archived=False, # config['show_archived'], show_deleted=False, # config['show_deleted'], show_history=False, # config['show_history'], app_config=app_config, ) } config['domaincontroller'] = TracimDomainController( presetdomain=None, presetserver=None, app_config=app_config, ) return config
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 _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 authentication mechanism 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: TracimDavProvider( 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(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 make_config(filesystem_provider, domain_controller_class): """ Create config for the WsgiDAVApp """ config = DEFAULT_CONFIG.copy() config.update({ "provider_mapping": {"/": filesystem_provider}, "http_authenticator": { "domain_controller": domain_controller_class, "accept_basic": True, "accept_digest": False, "default_to_digest": False, }, "verbose": 4, "enable_loggers": [], "property_manager": True, # True: use property_manager.PropertyManager "lock_manager": True, # True: use lock_manager.LockManager }) return config
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 _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 util.initLogging(config["verbose"], config.get("log_path", ""), config.get("enable_loggers", [])) util.log("Default encoding: %s (file system: %s)" % (sys.getdefaultencoding(), sys.getfilesystemencoding())) _loadSeafileSettings(config) 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 _initConfig(self): """Setup configuration dictionary from default, command line and configuration file.""" from tg import config as tg_config # Set config defaults config = DEFAULT_CONFIG.copy() temp_verbose = config["verbose"] # Configuration file overrides defaults default_config_file = os.path.abspath(DEFAULT_CONFIG_FILE) config_file = tg_config.get('wsgidav.config_path', 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 tracim.lib.webdav.tracim_http_authenticator import TracimHTTPAuthenticator from wsgidav.error_printer import ErrorPrinter from tracim.lib.webdav.utils import TracimWsgiDavDebugFilter config['middleware_stack'] = [ WsgiDavDirBrowser, TracimHTTPAuthenticator, ErrorPrinter, TracimWsgiDavDebugFilter, ] config['provider_mapping'] = { config['root_path']: Provider( # TODO: Test to Re enabme archived and deleted show_archived=False, # config['show_archived'], show_deleted=False, # config['show_deleted'], show_history=False, # config['show_history'], manage_locks=config['manager_locks']) } config['domaincontroller'] = TracimDomainController(presetdomain=None, presetserver=None) return 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 test_unit__initConfig__ok__nominal_case(self): """ Check if config is correctly modify for wsgidav using mocked wsgidav and tracim conf (as dict) :return: """ tracim_settings = { 'sqlalchemy.url': 'sqlite:///:memory:', 'user.auth_token.validity': '604800', 'depot_storage_dir': '/tmp/test/depot', 'depot_storage_name': 'test', 'preview_cache_dir': '/tmp/test/preview_cache', 'wsgidav.config_path': 'development.ini' } wsgidav_setting = DEFAULT_CONFIG.copy() wsgidav_setting.update({ 'root_path': '', 'acceptbasic': True, 'acceptdigest': False, 'defaultdigest': False, }) mock = MagicMock() mock._initConfig = WebdavAppFactory._initConfig mock._readConfigFile.return_value = wsgidav_setting mock._get_tracim_settings.return_value = tracim_settings config = mock._initConfig(mock) assert config assert config['acceptbasic'] is True assert config['acceptdigest'] is False assert config['defaultdigest'] is False # TODO - G.M - 25-05-2018 - Better check for middleware stack config assert 'middleware_stack' in config assert len(config['middleware_stack']) == 7 assert 'root_path' in config assert 'provider_mapping' in config assert config['root_path'] in config['provider_mapping'] assert isinstance(config['provider_mapping'][config['root_path']], Provider) # nopep8 assert 'domaincontroller' in config assert isinstance(config['domaincontroller'], TracimDomainController)
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 _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"] >= 4: print("Configuration({}):\n{}".format(cmdLineOpts["config_file"], pformat(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
# 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, 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
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.run_server import _runBuiltIn # _runBuiltIn(app, config, None) from wsgidav.server.run_server import _runCheroot _runCheroot(app, config, "cheroot")