def base(environ, start_response): """ The basic listing page that shows all available :py:class:`challenger systems <tiddlyweb.web.challengers.ChallengerInterface>`. If there is only one challenger, we redirect to that instead of listing. """ auth_systems = environ['tiddlyweb.config']['auth_systems'] if len(auth_systems) == 1: raise HTTP302(_challenger_url(environ, auth_systems[0])) start_response('401 Unauthorized', [('Content-Type', 'text/html')]) title = 'Login Challengers' header, footer = html_frame(environ, title) challenger_info = [] for system in auth_systems: challenger_uri = _challenger_url(environ, system) try: challenger = _get_challenger_module(system) challenger_label = getattr(challenger, 'desc', challenger_uri) challenger_info.append((challenger_uri, challenger_label)) except ImportError: pass output = [ '<li><a href="%s">%s</a></li>' % (uri, label) for uri, label in challenger_info ] return [header] + output + [footer]
def base(environ, start_response): """ The basic listing page that shows all available challenger systems. If there is only one, we redirect to that instead of listing. """ auth_systems = environ['tiddlyweb.config']['auth_systems'] if len(auth_systems) == 1: raise HTTP302(_challenger_url(environ, auth_systems[0])) start_response('401 Unauthorized', [('Content-Type', 'text/html')]) title = 'Login Challengers' header, footer = html_frame(environ, title) challenger_info = [] for system in auth_systems: uri = _challenger_url(environ, system) try: challenger = _get_challenger_module(system) label = getattr(challenger, 'desc', uri) challenger_info.append((uri, label)) except ImportError: pass output = ['<li><a href="%s">%s</a></li>' % (uri, label) for uri, label in challenger_info] return [header] + output + [footer]
def _send_cookie_form(self, environ, start_response, redirect, status='401 Unauthorized', message=''): """ Send a simple form to the client asking for a username and password. """ start_response(status, [('Content-Type', 'text/html')]) title = 'Cookie Based Login' header, footer = html_frame(environ, title) return [header, """ <p>%s</p> <form action="" method="POST"> <label> User: <input name="user" /> </label> <label> Password: <input type="password" name="password" /> </label> <input type="hidden" name="tiddlyweb_redirect" value="%s" /> <input type="submit" value="submit" /> </form> """ % (message, redirect), footer]
def base(environ, start_response): """ The basic listing page that shows all available :py:class:`challenger systems <tiddlyweb.web.challengers.ChallengerInterface>`. If there is only one challenger, we redirect to that instead of listing. """ auth_systems = environ["tiddlyweb.config"]["auth_systems"] if len(auth_systems) == 1: raise HTTP302(_challenger_url(environ, auth_systems[0])) start_response("401 Unauthorized", [("Content-Type", "text/html")]) title = "Login Challengers" header, footer = html_frame(environ, title) challenger_info = [] for system in auth_systems: challenger_uri = _challenger_url(environ, system) try: challenger = _get_challenger_module(system) challenger_label = getattr(challenger, "desc", challenger_uri) challenger_info.append((challenger_uri, challenger_label)) except ImportError: pass output = ['<li><a href="%s">%s</a></li>' % (uri, label) for uri, label in challenger_info] return [header] + output + [footer]
def _entitle(environ, start_response, *args, **kwds): try: header, footer = html_frame(environ, title) output = handler(environ, start_response, *args, **kwds) try: output = header + output + footer except TypeError: try: output = [header] + output + [footer] except TypeError: output = [header] + list(output) + [footer] except (KeyError, IndexError, TypeError): environ['tiddlyweb.title'] = title output = handler(environ, start_response, *args, **kwds) return output