Exemple #1
0
 def middleware(self, app):
     """
     Wrap the given application in an appropriate DevAuth and Security instance
     """
     from devauth import DevAuth, convert_ip_mask
     from deliverance.security import SecurityContext
     if self.dev_users:
         password_checker = self.check_password
     else:
         password_checker = None
     app = SecurityContext.middleware(
         app,
         execute_pyref=self.execute_pyref,
         display_local_files=self.display_local_files,
         edit_local_files=self.edit_local_files)
     if password_checker is None and not self.dev_htpasswd:
         ## FIXME: warn here?
         return app
     app = DevAuth(app,
                   allow=convert_ip_mask(self.dev_allow_ips),
                   deny=convert_ip_mask(self.dev_deny_ips),
                   password_file=self.dev_htpasswd,
                   password_checker=password_checker,
                   expiration=self.dev_expiration,
                   login_mountpoint='/.deliverance',
                   secret_file=self.dev_secret_file)
     return app
Exemple #2
0
    def middleware(self, app):
        """
        Wrap the given application in an appropriate DevAuth and Security instance
        """
        from devauth import DevAuth, convert_ip_mask
        from deliverance.security import SecurityContext

        if self.dev_users:
            password_checker = self.check_password
        else:
            password_checker = None
        app = SecurityContext.middleware(
            app,
            execute_pyref=self.execute_pyref,
            display_local_files=self.display_local_files,
            edit_local_files=self.edit_local_files,
        )
        if password_checker is None and not self.dev_htpasswd:
            ## FIXME: warn here?
            return app
        app = DevAuth(
            app,
            allow=convert_ip_mask(self.dev_allow_ips),
            deny=convert_ip_mask(self.dev_deny_ips),
            password_file=self.dev_htpasswd,
            password_checker=password_checker,
            expiration=self.dev_expiration,
            login_mountpoint="/.deliverance",
            secret_file=self.dev_secret_file,
        )
        return app
Exemple #3
0
"""
This sets up an example site
"""

import os
from paste.urlparser import StaticURLParser
from paste.httpserver import serve
from weberror.evalexception import EvalException
from deliverance.middleware import DeliveranceMiddleware, SubrequestRuleGetter
from deliverance.security import SecurityContext

base_path = os.path.join(os.path.dirname(__file__), 'example-files')
app = StaticURLParser(base_path)
deliv_app = DeliveranceMiddleware(app, SubrequestRuleGetter('/rules.xml'))
full_app = SecurityContext.middleware(deliv_app, execute_pyref=True, display_logging=True, display_local_files=True,
                                      force_dev_auth=True)

if __name__ == '__main__':
    print 'See http://127.0.0.1:8080/?deliv_log for the page with log messages'
    serve(EvalException(full_app))
Exemple #4
0
import os
import sys
from paste.urlparser import StaticURLParser
from paste.httpserver import serve
from weberror.evalexception import EvalException
from deliverance.middleware import DeliveranceMiddleware, FileRuleGetter
from deliverance.security import SecurityContext

base_path = os.path.join(os.path.dirname(__file__), 'example-files')
app = StaticURLParser(base_path)
rules_file = os.path.join(base_path, 'rules.xml')
deliv_app = DeliveranceMiddleware(app, FileRuleGetter(rules_file))
full_app = SecurityContext.middleware(deliv_app,
                                      execute_pyref=True,
                                      display_logging=True,
                                      display_local_files=True,
                                      force_dev_auth=True)

if __name__ == '__main__':
    try:
        port = sys.argv[1]
    except IndexError:
        port = '8080'
    host = '127.0.0.1'
    if ':' in port:
        host, port = port.split(':')
    print('See http://%s:%s/?deliv_log for the page with log messages' %
          (host, port))
    serve(EvalException(full_app), port=port, host=host)