Exemplo n.º 1
0
    def setup_environ(self):
        super(ServeApp, self).setup_environ()
        router_module_names = self.nappingcat_settings.get('routers')
        router_module_names = "" if not router_module_names else router_module_names
        self.routers = [(r'^', include(i)) for i in router_module_names.split('\n') if i]
        pubkey_handler_name = self.nappingcat_settings.get('public_key_handler', 'nappingcat.pubkey_handlers.AuthorizedKeysFile')

        self.public_key_handler = import_class_from_module(pubkey_handler_name)()
def main(name=None, key=None):
    name = sys.argv[1] if name is None else name
    key = sys.stdin.read() if key is None else key
    settings = build_settings()
    auth = get_auth_backend_from_settings(settings)
    pubkey_handler = dict(settings.items(SECTION_NAME)).get('public_key_handler', 'nappingcat.pubkey_handlers.AuthorizedKeysFile')
    pubkey_handler = import_class_from_module(pubkey_handler)()

    auth.add_user(name)
    auth.add_key_to_user(name, key)
    auth.add_permission(
        name,
        ('auth', 'adduser'),
    )
    auth.add_permission(
        name,
        ('auth', 'modifyuser'),
    )
    auth.finish(pubkey_handler)
    print "\033[0;32m%s\033[0m\n" % """
    You just created a super great super user!
    """.strip()